Hello,
I'm really desasperate and I hope to find someone to help me.
I have a project and I do recovery a data from an API with an ESP8266. from this API : https://api.eliapp.io/groups/bf203bd2-55d9-4975-ad73-eab097dc9528/monthlyStatistics/aggregate?m=["2023-05","2023-06"]
I succeed to connect my ESP to the page , but the answer is empty.
Here you'll can find my code :
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
ESP8266WiFiMulti WiFiMulti;
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.mode(WIFI_STA);
WiFiMulti.addAP("", ""); // Vos informations WiFi
// Attendez que la connexion WiFi soit établie
while (WiFiMulti.run() != WL_CONNECTED) {
delay(100);
}
}
void loop() {
if (WiFiMulti.run() == WL_CONNECTED) {
WiFiClientSecure client;
client.setInsecure();
HTTPClient http;
String url = "https://api.eliapp.io/groups/bf203bd2-55d9-4975-ad73-eab097dc9528/monthlyStatistics/aggregate?m=[%222023-05%22,%222023-06%22]";
http.begin(client, url);
http.addHeader("Accept", "application/json");
http.addHeader("User-Agent", "Mozilla/5.0");
int httpCode = http.GET();
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println("Réponse reçue :");
Serial.println(payload);
// Code pour analyser le JSON
} else {
Serial.print("Erreur lors de la requête HTTP: ");
Serial.println(http.errorToString(httpCode));
}
http.end();
} else {
Serial.println("WiFi non connecté");
}
delay(10000);
}
Thanks for your help