Code:
HTTPClient http; //Declare object of class HTTPClient
// ------------------------------URL---------------------------Port-------uri
httpCode = http.begin("https://www.sappush.com", 3000, "api1/devices/10/setWifi");
http.addHeader("Content-Type", "application/json"); //Specify content-type header
httpCode = http.POST("token:1234567890abc"); //Send the request
if(httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] POST... code: %d\n", httpCode);
// file found at server
if(httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
Code:
[HTTP] POST... failed, error: connection refused
Code:
POST /api1/devices/10/setWifi HTTP/1.1
HOST: http://www.sappush.com:3000
content-type: application/json
content-length: 25
{"token":"1234567890abc"}
Code:
{
"Ack": "Ok"
}
Statistics: Posted by blackpearl21 — Sat Apr 28, 2018 7:07 pm