Issue
How do i convert this cURL cmd into a batch script -
curl --request POST \
--url https://api.example.com \
--header "Authorization: Bearer token" \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "[email protected]"}]}],"from": {"email": "[email protected]"},"subject": "Subject","content": [{"type": "text/plain", "value": "Body"}]}'
this is the error that i am getting -
[Running] cmd /c "c:\Users\sendMail.bat"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: \
'--url' is not recognized as an internal or external command,
operable program or batch file.
'--header' is not recognized as an internal or external command,
operable program or batch file.
'--header' is not recognized as an internal or external command,
operable program or batch file.
'--data' is not recognized as an internal or external command,
operable program or batch file.
[Done] exited with code=1 in 0.078 seconds
Solution
Escape a new line with a ^
instead of a \
and for --data
turn '
into "
and "
into \"
:
curl --request POST ^
--url https://api.example.com ^
--header "Authorization: Bearer token" ^
--header "Content-Type: application/json" ^
--data "{\"personalizations\": [{\"to\": [{\"email\": \"[email protected]\"}]}],\"from\": {\"email\": \"[email protected]\"},\"subject\": \"Subject\",\"content\": [{\"type\": \"text/plain\", \"value\": \"Body\"}]}"
Answered By - Reino Answer Checked By - Timothy Miller (WPSolving Admin)