See subject. If I copy paste this:
http://192.168.1.90:8080/67eebdd9cde42b4ea52bc9292c72db35/get/V55
from my serial output into a browser I get:
[“1”]
however running my code I get:
request failed, httpCode: -11
How on earth can this happen?
Relevant code:
String APIreadDevicePin(String token, int pin){
String spin = String(pin); // convert pint number to string
HTTPClient http; // create: // http://192.168.1.90:8080/382222989c2zzdbdf28bf268807c7c/get/pin
String payload = "request failed";
String url = "http://192.168.1.90:8080/"; // url -- http://IP:port
url += token; // blynk token
url += "/get/V";
url += spin; // pin to read
http.begin(url);
Serial.println(url);
int httpCode = http.GET();
delay(50);
if (httpCode > 0) {
payload = http.getString(); // get response payload as String
payload.remove(0, 2);
payload.remove(payload.length() - 2); // strip [""]
}
else payload = payload + ", httpCode: " + httpCode;
http.end();
delay(10);
return payload;
}
the line: Serial.println(url);
is the line that produces the above url that I tested in a browser. The line that calls the API in my code is:
String relayState = APIreadDevicePin(auth_RLY, relayOn_PIN[ROOM-1]); // additional vpin state set by relay pins go from 0-6 rooms from 1-7