Can't parse inline keyboard button (Telegram bot)
При отправке sendMessage с телом
{
"chat_id": "{{MyChatId}}",
"text": "Inline Keyboard markup test-1",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Принято"
}
]
]
}
}
возвращает ошибку
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard"
}
Причина в том, что опциональные параметры у типа InlineKeyboardButton - не 100% опциональные. В инструкции https://core.telegram.org/bots/api#inlinekeyboardbutton написано: "You must use exactly one of the optional fields."
Если поправить запрос:
{
"chat_id": "{{MyChatId}}",
"text": "Inline Keyboard markup test-1",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Принято",
"callback_data": "yes"
}
]
]
}
}
то все проходит нормально:
{
"ok": true,
"result": {
"message_id": 1152,
"from": {
"id": ***,
"is_bot": true,
"first_name": "TestBot",
"username": "***"
},
"chat": {
"id": ***,
"first_name": "***",
"last_name": "***",
"username": "***",
"type": "private"
},
"date": 1618994920,
"text": "Inline Keyboard markup test-1",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Принято",
"callback_data": "yes"
}
]
]
}
}
}
Комментарии
Отправить комментарий