Sending SMS in twilio returns 21603 : A 'From' number is required

落花浮王杯 提交于 2019-12-01 21:15:11

The following works (from POSTMAN history)

POST /2010-04-01/Accounts/ACCOUND_SID/Messages.json HTTP/1.1
Host: api.twilio.com
Authorization: Basic Base64_encoding(ACCOUNT_SID:AUTH_TOKEN)
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded

Body=%22Test+1+-+urlencoded%22&From=%22%2BVALID_TWILIO_NUMBER%22&To=%22%2BMY_CELL%22

A few observations: This worked using POSTMAN in Chrome and HTTPRequester in Firefox (Authorization entered interactively through user/passwd dialog)

The Body, From, and To parameters MUST be spelled that way, if the first letter is lowercase, it will return the above error or similar.

That was the only Content-Type that worked - could not get it to work with a JSON request body (the way I posed it on the original question) - that remains an open issue.

I suggest that you use request parameters:

$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC5ef8732a3c49700934481addd5ce1659/Messages.json \
    -d "Body=Jenny%20please%3F%21%20I%20love%20you%20<3" \
    -d "To=%2B15558675309" \
    -d "From=%2B14158141829" \
    -d "MediaUrl=http://www.example.com/hearts.png" \
    -u 'AC5ef8732a3c49700934481addd5ce1659:{AuthToken}'

Additionally, I have seen that "No From Parameter" error when the phone number is not properly formatted.

I was trying to do this with Twilio's new WhatsApp messaging and was running into the same issue. Content-type was important, but also how the body of the POST request was formatted.

From=whatsapp:%2B441618507453&To=whatsapp:%2B17796758684&Body=Your appointment is coming up on {{July 21}} at {{3PM}}

Note the use of URL encoding for "+" symbols

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!