Receiving response from LAN only gives “{OK=NULL}”

(Raphael Hsieh) #1

I have a local server running that returns a simple JSON object ex. {body: 100}

I have a smartthings device handler that makes a hubaction and uses the sendHubCommand(hubAction) make a request to my local server

    def hubAction = new physicalgraph.device.HubAction(
	    method: "GET",
        path: "/",
        headers: [
    	   HOST: "<HOST IP>:<HOST PORT>"
    def result = sendHubCommand(hubAction)

I see the requests to my server when this is run, however my device handler does not receive the correct response message. Instead it only receives {OK: NULL} ?

What am I missing in order to receive data in my device handler ?


It’s probably doing the GET asynchronous, i.e. sendHubCommand is not waiting for the reply from your web service before it returns. See for how to define a callback function that will be called with the actual result object when your GET is done.