Corona case number ESP 8266

Hi Guys!

First of all, I'm a beginner and it's my first question on the forum ...

I would like to use the ESP 8266 to call up the current number of corona cases from the RKI website, which already provides the data I need in Json format. But I do not get any data from the website ... Hence the question: Am I basically overlooking something or does someone have an idea why I am not getting an answer?

Thanks!

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
 
const char* ssid = "SSID";
const char* password = "Passwort";
 
void setup () {
 
  Serial.begin(115200);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
 
    delay(1000);
    Serial.print("Connecting..");
 
  }
 
}
 
void loop() {
 
  if (WiFi.status() == WL_CONNECTED) { 
 
    HTTPClient http;  
 
    http.begin("https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/Coronaf%C3%A4lle_in_den_Bundesl%C3%A4ndern/FeatureServer/0/query?where=1%3D1&objectIds=13&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=LAN_ew_GEN%2C+Fallzahl%2C+Death%2C+cases7_bl_per_100k_txt&returnGeometry=false&returnCentroid=false&featureEncoding=esriDefault&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&datumTransformation=&applyVCSProjection=false&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnQueryGeometry=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&returnExceededLimitFeatures=true&quantizationParameters=&sqlFormat=none&f=pjson&token=");  
    int httpCode = http.GET();                                  
 
    if (httpCode > 0) { 
 
      String payload = http.getString();   
      Serial.println(payload);             
    }
 
    http.end();   
 
  }
 
  delay(30000);    
}

Your URL is very long. What happens if you run it through one of the URL shorteners and use the shorter URL? (This is just a guess.)

Also google for “esp8266 https” and attempt to find a simple example of a secure web client.
Your code appears to be suitable for a non-secure connection only so can only talk to a server which permits a connection over plain “http”.

You could try changing the url to remove the ‘s’ from “https” but most servers are configured to redirect such traffic back to https.

The url is, as has been pointed out, very long. You may need to use the http “post” method. You are currently using the http “get” method which can have a limit to the length of the url String.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.