Home > Back-end >  can not mark as read my incoming whatsapp message using whatsapp business api
can not mark as read my incoming whatsapp message using whatsapp business api

Time:07-07

Here's what I've done. I'm using Python programming language.

res = requests.put(
    url='https://graph.facebook.com/v13.0/messages/wamid.HBgMOTE4NzgwNDk1ODA0FQIAEhggQkU2OURGQUYyMzdCNDlBRkQ1QUI4RERBNDdENDBBOEIA', 
    header = {
        "Authorization": "Bearer my-auth-token",
        "Content-Type": "application/json"
    }, 
    data=json.dumps({"status": "read"})
)

print(res.json())

Output:

{'error': {'message': 'Unknown path components: /wamid.HBgMOTE4NzgwNDk1ODA0FQIAEhggQkU2OURGQUYyMzdCNDlBRkQ1QUI4RERBNDdENDBBOEIA', 'type': 'OAuthException', 'code': 2500, 'fbtrace_id': 'A6f8nCvHOSXSZcAGmevCGeJ'}}

CodePudding user response:

According to the documentation the url is supposed to look like this:

https://graph.facebook.com/v13.0/PHONE_NUMBER_ID/messages

You seem to be missing PHONE_NUMBER_ID in its correct place, and seem to have wamid... which doesn't seem to be needed here. I also notice that your request body is missing the required data:

"messaging_product": "whatsapp",
"status": "read",  <- you only seem to have this
"message_id": "MESSAGE_ID"

Also, the docs show a POST request while you seem to be using a PUT request. If you solve all these problems it should start working.

  • Related