I am trying to call firebase cloud function from ESP8266, it is working fine from postman but I am getting http response Code -1 in esp. below is the code, can anyone help me to find my mistake. Thanks
void loop() {
if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status
Serial.println("Still Connected !");
WiFiClientSecure client;
HTTPClient http;
http.begin(client, "https://us-central1-firedetectionapi.cloudfunctions.net/status"); //Specify destination for HTTP request
http.addHeader("Content-Type", "application/json"); //Specify content-type header
int httpResponseCode = http.POST("{"F":"T"}"); //Send the actual POST request
if(httpResponseCode>0){
Serial.println("API Called"); //Print return code
}else{
Serial.print("Error on sending POST: ");
Serial.println(httpResponseCode);
}
http.end(); //Free resources
}else{
Serial.println("Error in WiFi connection");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…