Page 1 of 1

Https request / Content-length = 0

Posted: Tue Sep 28, 2021 6:35 am
by Sergi_SP
Hi,

I have been able to get data from and API endpoint using esp_http_client_open() or esp_http_client_perform().

But now I can't because the server where I request for getting data has activate certificate authorization for some services. I always get content-length = 0.

However the endpoint I call is not protected usign certificate authorization. But if you call the endpoint usign a web browser you must skip a window popup requesting for a certificate. After skipping this popup you get the data because authorization is not required indeed.

Moreover if you use Curl command to call this endpoint you get the data without problems.

I've have seen a few examples using a port of curl command for esp32 devices but I haven't been able to make it working.

Are there other functions instead of esp_http_client_open() or esp_http_client_perform() I can try?

Including a certificate in my request is not an option because I have to mantaing compatibility with other devices that use certificates.

Please, may you help me?

Thanks in advance

Re: Https request / Content-length = 0

Posted: Tue Sep 28, 2021 7:33 pm
by chegewara
Its very old code, i believe its from before esp-idf v3, but you could try it:
https://github.com/nkolban/esp32-snippe ... aster/curl

I didnt use it myself.

Re: Https request / Content-length = 0

Posted: Wed Sep 29, 2021 4:10 pm
by jdoubleu
What status code do you get back from the API on the first call? Is it a "401 Unauthorized"?

I assume curl automatically re-tries your request if you didn't provide any information about client certificate authentication, like your web browser, which prompted you first.

I found this function in the documentation, but I'm not sure what it does or how it works. Especially when you want to provide a client certificate. But maybe you can try it out: https://docs.espressif.com/projects/esp ... t_handle_t
Especially

Re: Https request / Content-length = 0

Posted: Fri Oct 15, 2021 9:51 am
by Sergi_SP
Hi,

Finally the server admin excluded endpoints from certificate authorization.

Now it works as expected.

Thanks for your reply guys

Best regards