WIFIO is a dual Arduino WIFI module (ESP8266+ATMEGA328P) FCC approve-able with transferable licence. Can use the 328P for I/O expansion also...

Moderator: igrr

User avatar
By Saifkhan
#90174 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

Code: Select allvoid 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");   
 
 }