SuperCode
SuperCode

Reputation: 632

Failing to send media with Twilio Whatsapp Sandbox API?

Failing to send media via Twilio WhatsApp API using CURL, I only receive the text message but media is missing.

I been going through Twilio docs for sending media files. The command finishes correctly but on my phone I only receive the message Send Media with Twilio

curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages.json --data-urlencode "To=whatsapp:+263000000" --data-urlencode "From=whatsapp:+14155238886" --data-urlencode "Body=Thanks for contacting me on WhatsApp! Here is a picture of an owl." --data-urlencode “MediaUrl=https://demo.twilio.com/owl.png” -u "ACXXXXXXXXXXXXXXXXXXXx:authkey"

It should deliver an image file of owl to recipient in WhatsApp.

Upvotes: 0

Views: 607

Answers (1)

lizziepika
lizziepika

Reputation: 3300

Twilio Developer Evangelist here.

I used your cURL code which is from both the WhatsApp Media Support blog post and the Support page. This recreated your error: the numMedia Message property did not exist, but the message sent. A Message SID existed, but when I visited the subresource media URI, it said the requested resource was not found, status 404, and it gave this 20404 error page.

I found switching the double quotation marks around the image URL to single quotations to send the image (making numMedia and the subresource media URI exist. After the single quotations, using double quotations around the media URL did work as well so an image was sent.

curl -X POST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXX/Messages.json --data-urlencode "To=whatsapp:+263000000" --data-urlencode "From=whatsapp:+14155238886" --data-urlencode "Body=Thanks for contacting me on WhatsApp! Here is a picture of an owl." --data-urlencode 'MediaUrl=https://demo.twilio.com/owl.png' -u "ACXXXXXXXXXXXXXXXXXXXx:authkey"

Hope this helps!

Upvotes: 2

Related Questions