Weather station https problem

Hello

I’m trying to download data from api.met.no , but I can’t get data.
I found example that downloads data from github, modified just host, address and SHA1 fingerprint, but no success.
What’s wrong?
And could I have working example of XML parsing. Best I’ve found are just string finder function, but where’s good XML parser?

#include "settings.h"


#include <Arduino.h>
#include <ESP8266WiFi.h>


//Include the SSL client
#include <WiFiClientSecure.h>


//const char* host = "api.github.com";
const char* host = "api.met.no";
const int httpsPort = 443;

// Use web browser to view and copy
// SHA1 fingerprint of the certificate
//const char fingerprint[] PROGMEM = "5F F1 60 31 09 04 3E F2 90 D2 B0 8A 50 38 04 E8 37 9F BC 76";

const char fingerprint[] PROGMEM = "FF 8B 09 B0 7C 58 4D 49 31 D6 28 BD 36 48 80 8F 53 7F 5D 7B";

void setup() {

  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(WIFI_SSID);
  WiFi.begin(WIFI_SSID,WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);


  // Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);

  Serial.printf("Using fingerprint '%s'\n", fingerprint);
  client.setFingerprint(fingerprint);

  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

  //String url = "/repos/esp8266/Arduino/commits/master/status";
  String url = "/weatherapi/sunrise/2.0?lat=52.79&lon=2.83&date=2019-04-22&offset=+01:00";
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +

               "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0\r\n" +
               "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" +
               "Accept-Language: en-US,en;q=0.5\r\n" +
               "Accept-Encoding: gzip, deflate, br\r\n" +
               "Connection: keep-alive\r\n" +
               "Cookie: _ga=GA1.2.2041005525.1555932726; _gid=GA1.2.820650349.1555932726\r\n" +
               "Upgrade-Insecure-Requests: 1\r\n\r\n");

  Serial.println("request sent");
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String line = client.readStringUntil('\n');
  if (line.startsWith("{\"state\":\"success\"")) {
    Serial.println("esp8266/Arduino CI successfull!");
  } else {
    Serial.println("esp8266/Arduino CI has failed");
  }
  Serial.println("reply was:");
  Serial.println("==========");
  Serial.println(line);
  Serial.println("==========");
  Serial.println("closing connection");
}

void loop() {
}

Found out that fingerprint was wrong. use this. But still, nothing usefull coming out

const char fingerprint[] PROGMEM = "FF 8B 09 B0 7C 58 4D 49 31 D6 28 BD 36 48 80 8F 53 7F 5D 7B"

But still, nothing usefull coming out

What is coming out then?

Just random bytes. Nothing usefull.
Please somebody post me a working template. I can find chars from string. but without string I'm bit lost

I'm sure it would illuminating to print the line read from the server, instead of ASSuming that you know what is in the line.

Hello again

Code

#include "settings.h"


#include <Arduino.h>
#include <ESP8266WiFi.h>


//Include the SSL client
#include <WiFiClientSecure.h>


//const char* host = "api.github.com";
const char* host = "api.met.no";
const int httpsPort = 443;

// Use web browser to view and copy
// SHA1 fingerprint of the certificate
//const char fingerprint[] PROGMEM = "5F F1 60 31 09 04 3E F2 90 D2 B0 8A 50 38 04 E8 37 9F BC 76";

const char fingerprint[] PROGMEM = "FF 8B 09 B0 7C 58 4D 49 31 D6 28 BD 36 48 80 8F 53 7F 5D 7B";

void setup() {

  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(WIFI_SSID);
  WiFi.begin(WIFI_SSID,WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);


  // Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);

  Serial.printf("Using fingerprint '%s'\n", fingerprint);
  client.setFingerprint(fingerprint);

  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

  //String url = "/repos/esp8266/Arduino/commits/master/status";
  String url = "/weatherapi/sunrise/2.0?lat=62.79&lon=22.83&date=2019-04-22&offset=+03:00";
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +

               "User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0\r\n" +
               "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" +
               "Accept-Language: en-US,en;q=0.5\r\n" +
               "Accept-Encoding: gzip, deflate, br\r\n" +
               "Connection: keep-alive\r\n" +
               "Cookie: _ga=GA1.2.2041005525.1555932726; _gid=GA1.2.820650349.1555932726\r\n" +
               "Upgrade-Insecure-Requests: 1\r\n\r\n");

  Serial.println("request sent");
  while (client.connected()) {
//      String line = client.readStringUntil('\n');
//      if (line == "\r") {
//        Serial.println("headers received");
//        break;
//      }
//    }
    // if there are incoming bytes available
    // from the server, read them and print them:
    while (client.available()) {
      char c = client.read();
      Serial.write(c);
    }
  client.stop();
  }
//  String line = client.readStringUntil('\n');
//  if (line.startsWith("{\"state\":\"success\"")) {
//    Serial.println("esp8266/Arduino CI successfull!");
//  } else {
//    Serial.println("esp8266/Arduino CI has failed");
//  }
//  Serial.println("reply was:");
//  Serial.println("==========");
//  Serial.println(c);
//  Serial.println("==========");
//  Serial.println("closing connection");
}

void loop() {
}

Gives out to serial monitor

tail 8
chksum 0x2d
csum 0x2d
v951aeffa
~ld
Connecting Wifi: WLAN
.........
WiFi connected
IP address: 
192.168.0.38
connecting to api.met.no
Using fingerprint 'FF 8B 09 B0 7C 58 4D 49 31 D6 28 BD 36 48 80 8F 53 7F 5D 7B'
requesting URL: /weatherapi/sunrise/2.0?lat=62.79&lon=22.83&date=2019-04-22&offset=+03:00
request sent
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Thu, 25 Apr 2019 08:59:19 GMT
Content-Type: text/xml
Content-Length: 817
Connection: keep-alive
Last-Modified: Thu, 25 Apr 2019 08:59:19 GMT
Expires: Thu, 25 Apr 2019 09:05:47 GMT
X-Backend-Host: b_ybs_api3_a4_api_met_no
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: Origin
Content-Encoding: gzip
Vary: Accept, Accept-Encoding
X-Varnish: 762065450
Age: 0
Via: 1.1 varnish (Varnish/6.0)
Accept-Ranges: bytes

⸮

Please see attached pic because I can’t copy-paste that

PaulS:
Did you attach it to your forehead? With a nail gun?

I don't see any attachments or pictures.

Weird. There is a picture in my message.

The answer is compressed (gzip).

Why do you say to the server that you accept compressed results if you don't know how to handle it?

"Accept-Encoding: gzip, deflate, br\r\n" +

Yeah!
Thanks a lot!
This helped a lot more than PaulS could.
I copied those header lines from Firefox debugger that’s why those lines were there
This code is one step ahead

#include "settings.h"


#include <Arduino.h>
#include <ESP8266WiFi.h>

//Include the SSL client
#include <WiFiClientSecure.h>

const char* host = "api.met.no";
const int httpsPort = 443;

// Use web browser to view and copy
const char fingerprint[] PROGMEM = "FF 8B 09 B0 7C 58 4D 49 31 D6 28 BD 36 48 80 8F 53 7F 5D 7B";

void setup() {

  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was Previously
  // connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(WIFI_SSID);
  WiFi.begin(WIFI_SSID,WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);


  // Use WiFiClientSecure class to create TLS connection
  WiFiClientSecure client;
  Serial.print("connecting to ");
  Serial.println(host);

  Serial.printf("Using fingerprint '%s'\n", fingerprint);
  client.setFingerprint(fingerprint);

  if (!client.connect(host, httpsPort)) {
    Serial.println("connection failed");
    return;
  }

  String url = "/weatherapi/sunrise/2.0?lat=62.79&lon=22.83&date=2019-04-22&offset=+03:00";
  Serial.print("requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Accept: text/xml\r\n" +
               "User-Agent: ESP8266\r\n" +
               "Connection: close\r\n\r\n");

  Serial.println("request sent");
  while (client.connected()) {
    String response = client.readStringUntil('\n');
    Serial.println(response);
  }
  Serial.println("<-- Payload received");
  client.stop();
}

void loop() {
}