Sming - Open Source framework for high efficiency native ESP8266 development

User avatar
By helpme
#36556 I am trying to do a HTTP POST with SMING. From the documentation https://github.com/SmingHub/Sming, I can see an example for HTTP GET but not POST.

Code: Select allHttpClient thingSpeak;
...
thingSpeak.downloadString("http://api.thingspeak.com/update?key=XXXXXXX&field1=" + String(sensorValue), onDataSent);

void onDataSent(HttpClient& client, bool successful)
{
  if (successful)
    Serial.println("Successful!");
  else
    Serial.println("Failed");
}


Are there any sample code or example for doing HTTP Post?
User avatar
By bluegiraffe
#36984 Just need to set up a POST body. Something like this:

HttpClient httpServer;

...
httpServer.setPostBody("{}");
httpServer.setRequestContentType("application/json");
httpServer.downloadString(URL,onDataReceived);
...

This will do a POST operation instead of a GET to the server.

Edit: off course if needed you should change the post body from the empty JSON object to something else.