New SmartApp with web services


(David Frager) #1

I am attempting to create my first SmartApp using web services

From the browser, the following command works:
https://192.168.1.81:8080/api/4/apiVer

when I attempt an HttpGet request from my app,I get a ConnectTimeoutException

def apiParams = [
uri: “https://192.168.1.81:8080”,
path: “/api/4/apiVer”,
]
log.debug "parm: " + apiParams
try {
httpGet(apiParams) { resp ->
resp.headers.each {
log.debug “${it.name} : ${it.value}”
}
log.debug “response contentType: ${resp. contentType}”
}
} catch (e) {
log.debug “something went wrong: $e”
}


(Jim Anderson) #2

When I click that link the browser hangs on “connecting…”, and eventually resolves with ERR_CONNECTION_TIMED_OUT, which would explain the timeout exception.


#3

David,

If you take a look here: https://github.com/terafin/SmartThingsPublic/tree/master/devicetypes/terafin/airscape-whole-house-fan-controller.src

I have a simple local HTTP based device that (admittedly isn’t super clean), but works! I struggled getting it right for quite a while…

Let me know if that works out or not!


#4

Don’t think that will work for local addresses… Check out sendHubCommand