Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get 400 from requests.post in send_message because parameter should be json=data, not data=data #22

Open
mozboz opened this issue Aug 6, 2024 · 3 comments

Comments

@mozboz
Copy link

mozboz commented Aug 6, 2024

Pyhton 3.11.2 on Debian, was getting constant 400 when trying to do anything, e.g.

400 Client Error: Bad Request for url: https://graph.facebook.com/v20.0/12345678/messages

Turned out to be because the requests.post() parameter should be named json not data

i.e.

response = requests.post(
    url, json=data, headers=headers, timeout=10
)  # 10 seconds timeout as an example

Sorry don't have time to do a PR for this :(

@A00826925
Copy link

is 12345678 your PHONE_NUMBER_ID? where can i find that? i think thats the only issue i have since im also just receiving 400 client errors even after your fix

@manifestt
Copy link

manifestt commented Oct 8, 2024

I have the same error:
root - ERROR - Request failed due to: 400 Client Error: Bad Request for url: https://graph.facebook.com/v21.0/462219310303970/messages
werkzeug - INFO - 127.0.0.1 - - [08/Oct/2024 15:50:35] "POST /webhook HTTP/1.1" 200 -

1 - Send message from meta - OK
2 - Webhook - OK
3 - Send Message from test in webhook page meta - error 400 client error
4 - When send message from whatsapp - error 400 client error

How can i fix this?

@A00826925
Copy link

my problem was my .env file, i dont know what i did wrong, but for some reason whenever i updated it and saved it with the new keys, for some reason the file was completely ignored and used a previous version of the file that, as far as i know, didnt exist anymore. maybe something has not updated, clear your cache and try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants