Back to Smartcitizen.me

Sck api strange response to Arduino Querry


#1

I am trying to make a sck api query 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:

But if I make the same query from within an Arduino sketch like this (Based on the Arduino WifiWebClient example:

Then I get back a strange response like this:

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?

Thank you,
Drew


#2

Just a note: I tried putting the entire URL in the GET command like this:
client.println(“GET api.smartcitizen.me/v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json”);
client.println(“Host: api.smartcitizen.me”);

And actually got no response at all from the query.


#3

Well, I got the answer. I posted on the arduino website and got the answer.
I needed to add HTTP/1.1 to the end of the GET statement like this:

client.println(“GET /v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/me.json HTTP/1.1”);

After adding that, everything worked out fine.

Thanks , drew