Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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");   
  
 }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

The Arduino HTTP client requires a fingerprint/hash of the server's certificate when using the HTTPS protocol.

This can be setup with:

client.setFingerprint("81:dc:88:59:f1:fd:3b:f2:4a:27:c6:ba:39:44:3c:1c:16:4f:9c:ae");
http.begin(client, "https://us-central1-firedetectionapi.cloudfunctions.net/status");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...