Edit: I realize that the problem was with the certificate and I was not able to add it to this example. I switch to the esp_http_client, which has a certificate (that did not work for telegram), and in there I use the https examples. I had to change the certificate for it to work, I use the one is used in Universal Telegram Bot for Arduino, and then I was able to communicate with the page via GET, I'm trying to use POST now.
Edit 2: I was able to send the POST request. Here I let the example to communicate with a telegram bot.
I'm trying to communicate to my telegram bot using the https_request example in the ESP-IDF. On the long road I want the ESP32 to send data to the bot, but now I'am just trying to communicate with it. I believe I understand how the example works so I made these changes:
#define WEB_SERVER "https://api.telegram.org"
#define WEB_PORT "443"
#define WEB_URL "https://api.telegram.org/bot<your-bot-token>/getme"
The request from the example is:
static const char *REQUEST = "GET " WEB_URL " HTTP/1.0
"
"Host: "WEB_SERVER"
"
"User-Agent: esp-idf/1.0 esp32
"
"
";
It should respond something like:
{'id': 123456789, 'first_name': 'Test', 'is_bot': True, 'username': 'SlackOverflow', 'can_join_groups': True, 'can_read_all_group_messages': False, 'supports_inline_queries': True}
The error occurs in line 68, with esp_tls_conn_http_new:
E (3110) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x2700
E (3120) esp-tls: Failed to open new connection
Note: I just find this example that does HTTPS GET using plain mbedTLS sockets, but don't know if it differs a lot from the example I used.
Note 2: to learn about the example I used these defines and everything worked fine:
#define WEB_SERVER "www.swapi.dev"
#define WEB_PORT "443"
#define WEB_URL "https://swapi.dev/api/people/1/"
Note 3: I have seen that some people use a certificate (like this and this) but I'am not sure what they are or how/when to use it, I believe it is something for https, but I'm not sure.
Thanks.