HTTPRequest POST on ESP8266

Hello @alvarolb.
I have one question, how to send HTTP Request type POST through ESP8266. So I want to control led when I pressed the switch and it will send HTTPRequest POST and turn on the LED.

Here is my code :
HTTPClient http; //Declare object of class HTTPClient
http.begin(“”); //Specify request destination
http.addHeader(“Content-Type”, “application/json;charset=UTF-8”);
http.addHeader(“Authorization”, “Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjllbnQxIiwidXNyIjoiaXNqdXN0eW9nYTEifQ.mhXtY8QuhVLuUVbFHfprBgscU0t-HV99vz8hiq9qw”);//Specify content-type header
http.addHeader(“Accept”, “application/json, text/plain, /”);
int httpCode = http.POST(“in: true”); //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

SO, I am confusing in this part "int httpCode = http.POST(“in: true”); " is it correct to send value to “in” ? Because it’s not work to turn on the led in another device.

Hi @isjustyoga1, this is not correct. You should send a valid JSON, like {"in": true}. Please, take a look to the API explorer in the device to see a valid POST request.