rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.68k stars 1.18k forks source link

Invalid request json when sending messages #1019

Closed maxshengelia closed 2 years ago

maxshengelia commented 2 years ago

Hello, i faced with error "Telegram Bot API error when try to edit message: [400] Bad Request: message can't be edited"

In general, I found out that the bug is apparently in the Telegram Bot Java Library (https://github.com/rubenlagus/TelegramBots)

When sending a message via POST + json, the library specifies extra fields in json: reply_markup and method. Such a message is sent, but when trying to edit, the error happen: "[400] Bad Request: message can't be edited"

Json that is sent when this library sends a message:

{
  "chat_id": "740592393",
  "text": "original",
  "reply_markup": {
    "remove_keyboard": true
  },
  "method": "sendmessage"
}

If you remove the extra fields from the json of the sent message, then the message can be successfully edited.

Chase22 commented 2 years ago

Can you share the code used to setup the request? The library implementation is pretty straightforward and all fields are initialised to null

maxshengelia commented 2 years ago

Yes, it was my error, thanks. Closed the issue.