Ive been trying to get POST working on my ESP8266. I followed this tutorial https://techtutorialsx.com/2016/07/21/esp8266-post-requests/ which works, but once i change the request URL to anything else i get -1 response from http.POST() which the library returns when "no info".

I have no clue what the "no info" means and what im doing wrong. Does anyone have any suggestions? Below is the code im using.

if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
    HTTPClient http;    //Declare object of class HTTPClient
    //http.begin(""); //Works fine
    //http.begin("https://httpbin.org:8080/post"); //Causes -1 as httpCode
    //http.begin("https://httpbin.org/post"); //Causes -1 as httpCode
    http.addHeader("Content-Type", "application/json");  //Specify content-type header
    int httpCode = http.POST("{\"key\":\"1\",\"id\": \"ESPXXX2\",\"action\": \"rbg\",\"value\": \"255255000\"}");   //Send the request
    String payload = http.getString(); //Get the response payload
    Serial.println(httpCode);   //Print HTTP return code
    Serial.println(payload);    //Print request response payload
    http.end();  //Close connection
  } else {
    Serial.println("Error in WiFi connection");
  delay(10000);  //Send a request every 10 seconds

Only serial output im getting is "-1" for httpCode and empty line for payload.

  • 3
    Have you noticed the one thing that differs between all the URLs that fail and the one that works?
    – Majenko
    Commented Feb 7, 2021 at 12:28
  • so try again http.begin("https://httpbin.org/post"); with http.POST
    – Juraj
    Commented Feb 7, 2021 at 12:36
  • @Majenko, ESP8266HTTPClient library supports https
    – Juraj
    Commented Feb 7, 2021 at 14:52
  • @Juraj Yes. if you set it up right...
    – Majenko
    Commented Feb 7, 2021 at 14:53
  • @Majenko its the https thats causing the problem? I tried following another guide (circuits4you.com/2019/02/08/…) but still no luck, cant seem get past connect. Had no trouble doing this in postman, js and python.
    – Slurba
    Commented Feb 7, 2021 at 14:56

1 Answer 1


I ended up ditching HTTPS since it doesnt seem to be implemented all that well (Requires hardcoding of fingerprint). Changed the architecture of my system so that HTTPS is handled by Python which doesnt require jumping through hoops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.