0

I'm trying to send an audio to the whatsapp API, below the code and the return, it returns success but the audio does not arrive on the cell phone

SEND MEDIA

curl --request POST \
  --url https://graph.facebook.com/v17.0/xxxxxxxxxx/media \
  --header 'Authorization: Bearer EAAD....' \
  --header 'Content-Type: multipart/form-data' \
  --form file=@/Users/2_1687628467.mp3 \
  --form type=audio/mp3 \
  --form messaging_product=whatsapp

RETURN

{
    "id": "969850597766683"
}

SEND MESSAGE

curl --request POST \
  --url https://graph.facebook.com/v17.0/xxxxxxxxxx/messages \
  --header 'Authorization: Bearer EAAD...' \
  --header 'Content-Type: application/json' \
  --data '{
    "messaging_product": "whatsapp", 
  "recipient_type": "individual",
  "to": "MY_PHONE_NUMBER",
  "type": "audio",
  "audio": {
      "id": "969850597766683"
  }
}'

RETURN SEND MESSAGE

{
    "messaging_product": "whatsapp",
    "contacts": [
        {
            "input": "MY_PHONE_NUMBER",
            "wa_id": "MY_PHONE_NUMBER"
        }
    ],
    "messages": [
        {
            "id": "wamid.HBgMNTU2NTkyNjY1MDYwFQI=="
        }
    ]
}
ravenspoint
  • 19,093
  • 6
  • 57
  • 103
Nagi
  • 319
  • 1
  • 3
  • 11
  • You have to setup a webhook to track your issue, make sure you are aware of the rule that businesses can initiate a conversation by template-type messages only if the user replies then you can send other types of messages (media, text, etc) in 24 hours window. read more [here in my answer](https://stackoverflow.com/a/75856649/8987128). – turivishal Jun 25 '23 at 05:05
  • The Webhook affected me error, the format it was sending and incompatible RETUN Audio file uploaded with mimetype as audio\/ogg; codecs=opus, however on processing it is of type application\/octet-stream. Please choose a different file. "errors":[ { "code":131053, "title":"Media upload error", "message":"Media upload error", "error_data":{ "details":"Audio file uploaded with mimetype as audio\/ogg; codecs=opus, however on processing it is of type application\/octet-stream. Please choose a different file." } – Nagi Jun 25 '23 at 13:27

0 Answers0