Skip to content
Advertisement

Telegram bot sendMessage parse_mode generates HTTP/1.1 400 Bad Request

Using the HTTP API of telegram to send message in PHP like the following:

JavaScript

Just adding the last parameter &parse_mode=markdown causes 400 bad request. Removing it, everything works fine.

However, removing n from the $msg string makes it works fine.

Now, I don’t know why the new line n leads to 400 bad request. Also, I don’t know how to add new line to the message body!

Advertisement

Answer

urlencode() the msg;

JavaScript

enter image description here

The url is ended after the newline was found, therefore PHP cant send the request, resulting in a 400.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement