Hey folks,
I'm encountering an issue with an HTTP GET request to Firestore. After performing deserializeJson, the values I receive are sometimes null and other times valid, which is proving to be inconsistent.
Can anyone guide me on what might be going wrong?
bool readScheduleCollection() {
String url = firestore_base_url + "schedules?key=" + api_key;
client.setInsecure(); // Use this to disable SSL certificate verification (not recommended for production)
client.setBufferSizes(2048, 2048); // Increase buffer sizes for SSL
http.begin(client, url); // Updated to use WiFiClientSecure
int httpCode = http.GET();
if (httpCode == 200) {
String payload = http.getString();
Serial.println("Payload received:");
Serial.println(payload);
StaticJsonDocument<8192> doc; // Increase size as needed
DeserializationError error = deserializeJson(doc, payload);
Serial.println("Successfully read schedule collection:");
JsonArray documents = doc["documents"].as<JsonArray>();
String jsonArrayString;
serializeJson(documents, jsonArrayString);
Serial.println(jsonArrayString);
CustomSerial.println("SCHEDULES," + jsonArrayString);
return true;
} else {
Serial.println("Failed to read schedule collection");
Serial.println("Error: " + String(httpCode));
return false;
}
http.end();
}
Here's the output from th HTTP request
Here's the output after parsing it with json

