Good afternoon, I'm creating an application that sends a json to an http post on heroku through an esp8266, but I'm not having much success.
When making the request, the returned code is -11.
void sendToDatabase() {
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
HTTPClient http;
http.begin(client, serverName);
http.addHeader("Content-Type", "application/json");
DynamicJsonDocument doc(2048);
doc["acc_x"] = "TEST";//String(data.x);
doc["acc_y"] = "TEST";// = String(data.y);
doc["acc_z"] = "TEST";// = String(data.z);
doc["batery"] = "TEST";// = String(data.battery);
doc["current"] = "TEST";// = String(data.current);
doc["temperature"] = "TEST";// = String(data.temperature);
doc["key"] = "TEST";// = String(data.key);
String json;
serializeJson(doc, json);
int httpResponseCode = http.POST(json);
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
http.end();
} else {
Serial.println("WiFi Disconnected");
}
Serial.println();
}
I can make this request through postman, but through esp it doesn't work
