Page 1 of 1

urequests - Error sending to Telegram bot

Posted: Sat Jan 15, 2022 6:21 pm
by Frank
I've only recently gotten into ESPs and Micropython.
I want to send a message from ESP8266 (D1 Mini V3 NodeMCU ESP8266EX) to Telegram bot.

Code: Select all

import urequests
.
.
.
urequests.post("https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + str(chatId) + "&text=" + text)
Sending the message with the ESP32 is successful.
The ESP8288 comes with the following error message:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "urequests.py", line 120, in post
File "urequests.py", line 62, in request
OSError: -40


Is there a solution for this problem or can't I send to the bot with esp8266?

Re: urequests - Error sending to Telegram bot

Posted: Sat May 28, 2022 3:51 pm
by user_pico1
Frank wrote:
Sat Jan 15, 2022 6:21 pm
I've only recently gotten into ESPs and Micropython.
I want to send a message from ESP8266 (D1 Mini V3 NodeMCU ESP8266EX) to Telegram bot.

Code: Select all

import urequests
.
.
.
urequests.post("https://api.telegram.org/bot" + botToken + "/sendMessage?chat_id=" + str(chatId) + "&text=" + text)
Sending the message with the ESP32 is successful.
The ESP8288 comes with the following error message:

Traceback (most recent call last):
File "<stdin>", line 17, in <module>
File "urequests.py", line 120, in post
File "urequests.py", line 62, in request
OSError: -40


Is there a solution for this problem or can't I send to the bot with esp8266?
I have the same problem on Raspberry pi pico. Have you already solved it? Or could anyone help?
I can send requests to other sites, but it is not working with telergam.

Re: urequests - Error sending to Telegram bot

Posted: Sun May 29, 2022 12:09 am
by KJM
What happens if you substitute http for https ?

Re: urequests - Error sending to Telegram bot

Posted: Sun May 29, 2022 2:53 pm
by user_pico1
KJM wrote:
Sun May 29, 2022 12:09 am
What happens if you substitute http for https ?
In this case error "Redirects not yet supported"
But I have no problem with sending requests on https google.

Re: urequests - Error sending to Telegram bot

Posted: Mon May 30, 2022 6:36 am
by KJM
sadly urequests can't handle redirects and there is no ussl in upython for the 8286