everyone. I have following code:
url = "url"
headers = {'Content-type': 'application/json'}
bot = telebot.TeleBot('xxx')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, message.chat.id)
bot.send_message(message.chat.id, message.chat.username)
data = {"userId": "message.chat.username", "chatId": "message.chat.id"}
answer = requests.post(url, data=data, headers=headers)
print(answer)
Answer is 400. But when I use Postman with raw JSON: {"userId":"xxx", "chatId": "xxx"}
It gives me 200.
Can't understand the difference. Thank you.
Maybe problem with data. No?
data = {"userId": f"{message.chat.username}", "chatId": f"{message.chat.id}"}
instead of
data = {"userId": "message.chat.username", "chatId": "message.chat.id"}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments