Get Json as String from URL

Hey everybody

I wrote a sketch in processing, that calls an url (https://www.worldtides.info/api?heights&lat=33.768321&lon=-118.195617&key=XXX) which responds a json formated text like this:

(...)[{"dt":1515079800,"date":"2018-01-04T15:30+0000","height":0.5},(...) etc..

it then plots the data to a graph (see below).

Now i'm trying to do the same with an arduino mkr1000, e.g. call this url an then get the text (extract the data in it and use it for positioning of two stepper motors). i used the example with the www.arduino.cc/asciilogo.txt (link). However, i can't get anything but this asciilogo.txt from it (no other .txt from the web will show on the serial monitor) and the json-text from worldtides.info also not.

I saw that in all examples, that used the Get-request, that the url ended on a .json, but not the one i'm trying to parse.

Has anyone an idea to get this working?

Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
  Serial.println("connected to server");
  // Make a HTTP request:
  client.println("GET /api?heights&lat=33.768321&lon=-118.195617&key=1f01e37b-d86b-4adb-a4ec-80cfdc4331db HTTP/1.1");
  client.println("Host: https://www.worldtides.info");
  client.println("Connection: close");
  client.println();
}
}

tide.ino (3.43 KB)

Your problem is the used URL, it's HTTPS and Arduinos are not able to do SSL/TLS (not enough RAM and CPU power). Use a service that is accessible by HTTP or install a proxy on the internet that terminates the SSL so you can access it by HTTP (ensure that you don't set up an open proxy that allows access to the whole Internet!).