Search code examples
facebook-graph-apiwhatsapp

Whatsapp API not actually sending media message


I am trying to send an image via the Whatsapp API, but failing. I have uploaded an image, have the media ID and can download it with curl. Even an image link doesn't work - I don't get any error, in fact the response looks totally fine! Here's what I tried;

Trying to send an image as uploaded media with ID

curl -X  POST \
 'https://graph.facebook.com/v15.0/XXX/messages' \
 -H 'Authorization: Bearer XXX' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "XXX",
  "type": "image",
  "image": {"id" : "XXX"}
}'
# response: 
# {"messaging_product":"whatsapp","contacts":[{"input":"XXX","wa_id":"XXX"}],"messages":[{"id":"wamid.XXX"}]}

Trying to send an image as a link

curl -X  POST 'https://graph.facebook.com/v13.0/SENDER/messages' \
  -H 'Authorization: Bearer XXX' \
  -H 'Content-Type: application/json' \
  -d '{ 
  "messaging_product": "whatsapp", 
  "recipient_type": "individual", 
  "to": "XXX", 
  "type": "image", 
  "image": { "link" : "https://placekitten.com/500/500" }
}'
# response:
# {"messaging_product":"whatsapp","contacts":[{"input":"XXX","wa_id":"XXX"}],"messages":[{"id":"wamid.XXX}]}

Both seem OK, but I don't actually receive anything. When I send with a message template, that works fine immediately.


Solution

  • Well, two days later my request started to both suddenly work without me changing anything. It seems my account or project or something might have been in some kind of verification cycle that didn't allow sending media.