If copy/paste the print in the postman, works! but in Python give error
This is my code
array = '{"chat_id": "' + chat_id + '", "text": "Test Buttons", "reply_markup" : { "inline_keyboard" : [[ { "text" : "web", "url" :"google.es"}]]}}'
data3 = json.loads(array)
print(array)
url = f'https://api.telegram.org/bot{token}/sendMessage'
response = requests.get(url, params=data3)
print(response.json())
The error is
{'ok': False, 'error_code': 400, 'description': "Bad Request: can't parse reply keyboard markup JSON object"}
The print is
{"chat_id": "123XXX", "text": "Test Buttons", "reply_markup" : { "inline_keyboard" : [[ { "text" : "web", "url" :"google.es"}]]}}
Resolved
Send Telegram keyboard with Python
2
Answers
You seem to have used the wrong key for your second button’s text, you should use
text
.Looks like Telegram API accepts string in the key
reply_markup
, so you can stringify the object before making a post request.