How to pass keyboard in post request?

Viewed 26

Code:

url = f"https://api.telegram.org/bot{token}/sendDocument"
data = {
    'chat_id': message.chat.id,
    'caption': 'Тест пройден ',
    'reply_markup': json.dumps(kb_result)}

with open('Result.jpg', 'rb') as f:
    files = {'document': f}
    r = requests.post(url, data=data, files=files)
    print(r.json())

Keyboard code:

kb_result = {
    "keyboard_for_get_request": [
      [
        {"text": " Тест"},
        {"text": "⚙ Налаштування"}
      ],
      [
        {"text": "✍ Зв'язок"}
      ]
    ]
  }

The request is executed without errors, but the keyboard doesn`t appear in the end, what is the error?

And one more question, my button was originally created by the ReplyKeyboardMarkup type of the aiogram library, for the post request I rewrote it in the form of json, was it possible somehow to automatically rewrite the usual buttons in json or somehow unpack them to immediately send a post request?

0 Answers
Related