httpGet

Has anyone successfully retrieved data out of a web call? I have the below code along with results.

def successWebcall = { response ->
log.debug “Response was successful, $response”
}

def params = [
uri: “http://home.automation.server/IsAnyoneInTheHouse.php”,
success: successWebcall
];

httpGet(params);

}

The above code returns: Response was successful, groovyx.net.http.HttpResponseDecorator@2162e9b7

I’ve looked up groovyx.net.http.HttpResponseDecorator and found there are many methods out there but I haven’t figured out how to access that data within SmartThings. 1) Has anyone been able to retrieve data from a website, and 2) is there an easy way for me/anyone to determine what is inside an object via a debug statement (or something).

Thanks in advance!

I fought with this very thing yesterday.

response.data should give you a string with the body of the response.

If your response is json (and has a valid content type application/json) you can use response.data.item to get json bits. Example: response.data.temperature gives me the temperature from my response.

That may work with XML as well, but I haven’t tried it.

As far as an easy way to debug, I haven’t found one yet.

Perfect–THANKS, works great!