Nodemcu device is returning HTTP response -1 for a POST request on django rest api.
I tried the below http request to Postman, and it works perfectly fine.
This is my arduino post request:
if(WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(host_url);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpCode = http.POST(postData);
payload = http.getString();
http.end();
}
The expected result is 200, but I get -1. Can someone please explain?
host_url
andpostData
are not shown ... your code is sending unknown data .. therefore there is nothing to explain – jsotola Sep 3 '19 at 3:36http://localhost:8000
and the postData is"plant="+String(host)+"plants/1/&light="+String(lux)+"&temperature="+String(temperature)+"&humidity="+String(humidity)+"&soil="+mRes+"&moisture="+mVal+"&remarks=/";
I think the issue might be localhost jsotola – Tanveer Hoque Sep 11 '19 at 20:22