HTTPS POST method in esp32 (Getting Server response 400).

I was trying to connect with my server. But, I was unable to post the data. The server is HTTPS.

* set SSL/TLS certificate */
//////////////////////////////// try to connect to server again and POST the data on the cloud //////////////////////////
  if (!client.connect(host, httpsPort)) 
   Serial.println("Connection failed!");
    } else {
        Serial.println("Connected to server!");
   client.println("POST /devices/deviceData HTTP/1.1");
  client.println("Host: api.thi***");
  client.println("cache-control: no-cache");
  client.println("Content-Type: application/json");
  client.println("Authorization: Bearer eyJ0e***");
  client.println("Postman-Token: b1f4e147-8d13-4a27-a1a9-b****");
  client.print("Content-Length: ");
//////////////////////////////////POSTING the data on to the cloud is done and now get the response form cloud server//////////////////
 Serial.print("Waiting for response ");
  while (client.available() == 0) 
    if (millis() - timeout > 50000) 
      Serial.println(">>> Client Timeout !");
  Serial.println("Response From Server");
    char c =;

Can I know, why I am getting server response 400 again and again?

remove the empty line before the content-length header


Thanks for reply.
I have removed the empty line above Content-Length. But, still i am getting the same issue. I am trying to use HTTPS POST.
The error is "HTTP/1.1 400 Bad Request".
Please check it.


Is anyone there?
:confused: :confused:

Try it first with GET method, I can help you if you want.
E-mail me: