ESP32 AT command example for HTTPS API with bearer token and json

Dominykas Litvaitis
Posts: 2
Joined: Tue Mar 18, 2025 6:53 pm

ESP32 AT command example for HTTPS API with bearer token and json

Postby Dominykas Litvaitis » Wed Mar 26, 2025 6:24 am

Hello,

I cannot for the life of me figure out, how to send a HTTPS POST with bearer token and json content.

I am able to GET data with HTTPS like this:

Code: Select all

AT+CIPSTART="SSL","www.esp32.com",443
AT+CIPSEND=88

GET https://www.esp32.com/index.php HTTP/1.1
Host: www.esp32.com
Connection: close
So the ESP32 works, but I can not figure it out, how to translate this:

Code: Select all

POST /abcde/rest/datasetData/dataInfoRecent HTTP/1.1
Host: abcdef.abcde.com
Authorization: bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Content-Type: application/json
Content-Length: 46

[
    "52256:REMOTE_CATEGORIZED_DATASET"

]
I tried multiple variations of this:

Code: Select all

AT+CIPSTART="SSL","www.abcdef.abcde.com",443
AT+CIPSEND=278


POST /abcde/rest/datasetData/dataInfoRecent HTTP/1.1
Authorization: bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Content-Type: application/json
Host: abcdef.abcde.com
Content-Length: 46
 
[
"52256:REMOTE_CATEGORIZED_DATASET"
]
I get OK, so the length is okay, but then after like 5 seconds the connection closes. That means something is wrong in how I formatted the command.

The other thing, is I believe that the POST itself is correct. I was able to get it working in Postman. Then I just took the HTTP code snippet from Postman.

So all in all, the POST is correct and the ESP32 definitely works, that means the problem is I cannot format the request correctly for it to work. Any ideas?

esp-at
Espressif staff
Espressif staff
Posts: 335
Joined: Mon May 09, 2022 3:00 am

Re: ESP32 AT command example for HTTPS API with bearer token and json

Postby esp-at » Wed Mar 26, 2025 11:15 am

could you please use `curl` tool to post a http post request?
If it works, you can append the `--verbose` or `--trace dump.txt` to the curl command, and see more talkative logs.

And then you can make the same http request header on esp32 to the curl.

Who is online

Users browsing this forum: No registered users and 1 guest