I'm trying to send a media message with WhatsApp but I receive Error - 12300 Invalid Content-Type. I'm following the instructions from documentation but doesn't work. I'd sent successfully a lot of messages with images using the same code.
I'd sent successfully a lot of messages with images (jpg files) using the same code. I'd try with mp3, mp4, ogg and aac file types but not working.
function enviaQR(telefonoDestino) {
twilioClient.messages
.create({
from: 'whatsapp:+14155238886',
to: telefonoDestino,
body: '¡Listo, ahora a cumplir tus sueños!',
mediaUrl: 'https://firebasestorage.googleapis.com/v0/b/xxxxxxxdemo-99999.appspot.com/o/10999992_confirmacion.mp3?alt=media&type=audio&Content-Type=audio/mp3&token=d22c70ba-b123-4670-8a11-kljsdfy9sdcskl'
})
.then(message => {
console.log(message.sid);
})
.catch(err => {
console.error(err);
});
This is the error message in Twilio console:
Error - 12300 Invalid Content-Type Twilio is unable to process the Content-Type of the provided URL. Please see the Twilio Markup XML Documentation for more information on valid Content-Types.
You must return a Content-Type for all requests. Requests without a Content-Type will appear in the Debugger as a 502 Bad Gateway error.
Possible Causes
Having a phone number, outgoing call request or action attribute refers to a non-XML or audio resource.
Having a Play verb attempt to play non-audio content, such as XML or text.
Possible Solutions Verify that your web server is returning a Content-Type and it is the expected value Make sure the URL noted refers to a valid resource
Message Msg "Attempt to retrieve MediaUrl returned an unsupported Content-Type."