Answer the question
In order to leave comments, you need to log in
How to correctly form a POST request?
When I try to attach ReplyKeyboard markup, it doesn't send me a keyboard, the message text stops sending too. How can I correctly formulate a POST request?
def send_message(chat_id, text, reply_markup=None):
method = "sendMessage"
token = get_from_env("TOKEN")
url = f"https://api.telegram.org/bot{token}/{method}"
data = {"chat_id": chat_id, "text": text, "reply_markup": reply_markup}
requests.post(url, data)
send_message(
chat_id=request.json["message"]["from"]["id"],
text='Неправильно, это же ' + str(answer).lower() + '. Стыдно не знать!',
reply_markup={"keyboard": }
)
Answer the question
In order to leave comments, you need to log in
Need to convert this dictionary to JSON string
imprort json
data = {"chat_id": chat_id, "text": text, "reply_markup": json.dumps(reply_markup)}
data = {"chat_id": chat_id, "text": text, "reply_markup": reply_markup}
requests.post(url, json=data)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question