I checked everything to make it work but every time it does it's job 3 to 5 times then reports error -1.
Here is my code for sending POST:
HTTP.begin(ESP_HTTP_ADDRESS);
HTTP.setTimeout(300);
HTTP.addHeader("Content-Type", "application/json");
HTTP.addHeader("Content-Length", String(JSON.length()));
int RESPONSE = HTTP.POST(JSON);
if (RESPONSE != HTTP_CODE_OK) {
Serial.print(F("Query submit failed: "));
Serial.println(RESPONSE);
} else {
Serial.println(F("Query submit successful."));
Serial.println(F("Reading HTTP response:"));
String RESULT = HTTP.getString();
Serial.println(RESULT);
}
HTTP.end();
Could you please guide me to resolve this problem? Thanks.