I am trying to send an SMS message using Twilio API in Windows 10. I enter the following request in CMD:
curl "https://api.twilio.com/2010-04-01/Accounts/ACAccount SID/Messages.json" -X POST \
--data-urlencode "To=+Phone number" \
--data-urlencode "From=+Phone number" \
--data-urlencode "Body=Ahoy" \
-u Account SID:Auth Token
And I encounter:
{"code": 20003, "detail": "Your AccountSid or AuthToken was incorrect.", "message": "Authentication Error - No credentials provided", "more_info": "https://www.twilio.com/docs/errors/20003", "status": 401}curl: (6) Could not resolve host: \
I looked up the error message from the url provided but I couldn't get much information. I verified the Auth token and SID are correct. I am using Twilio free trial account if that makes a difference. I have given up troubleshooting. Any advice would be greatly appreciated.
The error message says curl: (6) Could not resolve host: \
indicating that the backslash was interpreted as the URL.
You said you're on Windows 10 in the command prompt, the backslash \
is used in Bash in Linux to split long commands over multiple lines. If you're on Windows you would need to replace \
with ^
, see this SO question.
So this should work under Windows 10 in the command prompt:
curl "https://api.twilio.com/2010-04-01/Accounts/ACAccount SID/Messages.json" -X POST ^
--data-urlencode "To=+Phone number" ^
--data-urlencode "From=+Phone number" ^
--data-urlencode "Body=Ahoy" ^
-u Account SID:Auth Token