Telegram bot API no JSON POST data on webhook

7.3k views Asked by At

I can't seem to get the JSON POST data of the webhook. I set up everything correctly (the webhook URL, also tested if the server is getting POST requests) and the requests are coming when the user posts something, but no POST nor GET data is logged. Is this a common bug or is it just me?

3

There are 3 answers

4
Emad Ghasemi On BEST ANSWER

As they said:

we will send an HTTPS POST request to the specified url, containing a JSON-serialized

It's a post, but they didn't mentioned any parameter for us to get it, just a JSON value, so try get the raw input.

For example in PHP I got it by using: file_get_contents('php://input')

2
Seeya On

UPDATE

A self signed cert is valid now.

0
SurfMan On

Also, another reason for not getting POSTs is that the certificate chain could be incorrect. No errors show on Firefox, but Chrome for Android complained.

It's explained in this thread on Reddit: https://www.reddit.com/r/Telegram/comments/3b4z1k/bot_api_recieving_nothing_on_a_correctly/

As soon as I added the chain certificate file and restarted Apache, the requests started coming in.