How to capture a http GET response

As a complete newbie to Electric Imp, Squirrel and http protocols, I wondered if anyone could help me with a problem I’m having sending data from Electric Imp to a database and obtaining a response.

So far I’ve managed to send a formatted URL to a web site hosting an SQL data base, using the Agent http.get method (I also tried http.post method, but got parameter errors). The URL contains information which enters the data into fields -this data entry method may appear clumsy, but it’s working OK.

However, there should be a response from the web site but I can’t seem to get hold of this response to verify what it says. As you can see from the attached screen shot of the Agent code and server log, I’m printing the URL string, the GET request and the response. The response always comes back as “(table : 0x7f33********)”. Is this some sort of pointer base address in RAM? If so, is it likely to contain the response as a series of ASCII characters? How can I access this and convert to a string?

Any suggestions greatly appreciated.

try this

foreach(k , resp in response){ server.log(k + " : " + resp); }

@AndyBentley - the response object that is returned is a Squirrel table. Squirrel tables are structured data objects (essentially a collection of key/value data).

You can find more information about the returned table here.

When a web request returns, there are typically two main pieces of data we care about: the status code (response.statuscode), and the body (response.body).

Many thanks for your help guys. I can now successfully read the response body and status code!