I am trying to make a api query to a smart citizen kit (sck) from inside an Arduino sketch.
If I just enter this api query in a browser window menu bar:
http://api.smartcitizen.me//v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json
Then I get the proper sck api response in the browser window:
{"me":{"id":"8","username":"mdeheras","city":"Barcelona","country":"Spain","website":"","email":"mdeheras@gmail.com","created":"2013-04-24 18:04:46","role":"citizen","devices":[{"id":"3","title":"SCK Hospitalet","description":"","location":"Hospitalet de Llobregat, Espa\u00f1a","city":"Hospitalet de Llobregat","country":"Espa\u00f1a","exposure":"outdoor","elevation":"100.0","geo_lat":"41.369310000000000","geo_long":"2.118000000000000","created":"2013-05-29 21:06:56 UTC","last_insert_datetime":"2014-03-24 01:00:44 UTC"},{"id":"41","title":"SCK Hangar","description":"","location":"Hangar, Poble Nou","city":"Barcelona","country":"Spain","exposure":"indoor","elevation":"12.0","geo_lat":"41.408420000000000","geo_long":"2.199940000000000","created":"2013-04-25 18:34:47 UTC","last_insert_datetime":"2014-03-27 13:22:16 UTC"},{"id":"333","title":"SCK_v1.1_proto","description":"","location":"Barcelona, Espa\u00f1a","city":"Barcelona","country":"Espa\u00f1a","exposure":"indoor","elevation":"0.0","geo_lat":"41.408650000000000","geo_long":"2.199620000000000","created":"2013-09-25 16:33:11 UTC","last_insert_datetime":"2015-07-09 19:02:55 UTC"},{"id":"549","title":"SCK_v1.1_KickStarter","description":"","location":"B, Espa\u00f1a","city":"B","country":"Espa\u00f1a","exposure":"indoor","elevation":"0.0","geo_lat":"41.408787694438730","geo_long":"2.199398109625249","created":"2014-01-16 13:04:50 UTC","last_insert_datetime":"2015-04-14 08:54:15 UTC"},{"id":"2389","title":"Smart Citizen TFM","description":"","location":"Barcelona, Spain","city":"","country":"","exposure":"indoor","elevation":"0.0","geo_lat":"41.410870161481420","geo_long":"2.150874137878418","created":"2015-07-10 14:50:11 UTC","last_insert_datetime":"2015-07-20 14:09:01 UTC"}]}}
But if I make the same query from within an Arduino sketch like this (Based on the Arduino WifiWebClient example):
WiFiClient client;
client.println("GET /v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json");
client.println("Host: api.smartcitizen.me");while (client.available()) {
char c = client.read();
Serial.write(c);
Then I get back a strange response like this:
404 Not FoundNot Found
The requested URL /v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json was not found on this server.
Apache/2.4.7 (Ubuntu) Server at analytics.smartcitizen.me Port 80
Which is nothing like the response that I am looking for (the first response from above). It is strange for two reasons. First it looks like HTML code instead of the text response I am looking for (I can kind of understand how that is happening). Second, it is saying the requested URL was not found. I am pretty sure that I broke apart the URL into the "host" and "get" statements properly.
Any idea what I might be doing wrong? How can I get back the nice sck API response from such a query?
I tried changing the GET command in these ways with no luck:
client.println("GET api.smartcitizen.me/v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json");
and
client.println("GET v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json");
Thank you,
Drew