Search code examples
twilio-api

SMS Message with Twilio and media using MediaUrl


I am submitting an SMS via Twilio's SMS API . Each time I try to send a message with the MediaUrl parameter I get the the following response:

{ "code": 21620, "message": "Invalid media URL(s)", "more_info": "https://www.twilio.com/docs/errors/21620", "status": 400 }

I have tried using PostMan as well with the same results. It doesn't seem to like the way that the array is formatted even though it follows the same format of the Twilio documentation.

["https://somesite.com/media/HR/65-652943_banner-stock-cartoon-girls-clipart-cartoon-people-happy.png","https://somesite.com/media/HR/android-chrome-192x192.png"]

I have tried a single element array, wrapping the JSON string in single quotes, removing the brackets entirely, but no matter what I try It still tells me that I have an "Invlaid media URL(s)" error.

My Postman configuration is below.

Postman screenshot

I've tried using the option for x-www-form-urlencoded instead of form-data as well with the same results.

This should be a simple fix but I am just not seeing it. If anyone else can shed any light on the subject it would be much appreciated. I am using Coldfusion to make the API call but if I can figure this out through Postman I think I can get it going in CF.


Solution

  • I did a test and was able to send the MMS using one of the images but one is causing an error.

    This image (https://..../media/HR/65-652943_banner-stock-cartoon-girls-clipart-cartoon-people-happy.png) is generating an error 12300:

    Twilio is unable to process the Content-Type of the provided URL. Please see Twilio's documentation on accepted content types for more information on valid Content-Types.

    According to this Stackoverflow post, the image isn't actually a png even though it has a .png file extension. I viewed the file in a hex editor and the first bytes aren't correct for a png.

    Try opening the image in an image editor and re-saving as either a png or jpg then try sending again.