SmartThings Community

httpPostJson UndeclaredThrowableException


#1

Hi there,
I’m trying to write a SmartApp to enable my ST sensors to communicate with my SmartHome system (Digitalstrom). The manufacturer offers a JSON interface to do so. Looking onto the developer docs as well as examples I found online I created below code, which throws “something went wrong: java.lang.reflect.UndeclaredThrowableException” all the time…
Could anyone point me to the root cause/solution?

Thanks
Hendrik

def params = [
uri: “http://XYZ.hopto.org/api.php”,
body: [
message:“init”,
protocol:“simple”,
uniqueid:“abc123”,
name:“myDoorSensor”,
group:8,
vendorname:“SmartThings”,
iconname:“SmartThings_icon”,
inputs:[
inputtype:14,
hardwarename:“myDoorSensor2”
]
]
]

def initialize() {
try {
httpPostJson(params) { resp ->
resp.headers.each {
log.debug “${it.name} : ${it.value}”
}
log.debug “response contentType: ${resp.contentType}”
}
} catch (e) {
log.debug “something went wrong: $e”
}
}


(Mark C) #2

you could try this, i had an issue recently sending post messages adding this into you params
tlsVersion: “TLSv1.1”,

or i cant see any login details
or just do log.debug " $resp" to see if anthing comes back
or put a log.debug “$params” in and copy/past into postman to test the message outside of smartthings


#3

thanks a lot. I figured out the root cause: the destination webserver script was having an issue but did not report. After fixing it works now!