softwarecrash/Solar2MQTT

HTTPS Requests

Closed this issue · 1 comments

A clear and concise description of what the problem is.

I'm trying to send data to Firebase realtime database using HTTP REST API.
I'm using the below code

` StaticJsonDocument<200> doc;
doc["name"] = "John Doe";
doc["age"] = 30;
doc["email"] = "john.doe@example.com";

char jsonBuffer[512];
serializeJson(doc, jsonBuffer);

// Firebase URL with authentication token
String url = String("https://") + firebaseHost + "/users/user123.json?auth=" + firebaseAuth;
Serial.println(url);

// Send HTTP PUT request
HTTPClient http;
http.begin(wifiClient, url); // Specify the URL
http.addHeader("Content-Type", "application/json"); // Specify content-type header
int httpResponseCode = http.PUT(jsonBuffer); // Send the request

if (httpResponseCode > 0) {
String response = http.getString(); // Get the response to the request
Serial.println(httpResponseCode); // Print return code
Serial.println(response); // Print request answer
} else {
Serial.print("Error on sending PUT request: ");
Serial.println(httpResponseCode);
}
`

but the request failed with error code -1, and the error message says that the connection failed.
I'm calling this code from loop method, after Wifi connection.
How can I send HTTPS requests?

Additional context

No response

i dont support miscellaneous rewrites of my code.

just a hint:

  • HTTP Rest API != HTTPS
  • ESP8266 doesnt have real power for ssl ecrypted communication.
  • when modify and use my code respect the license