Hi All
Just thought I would share a recent discovery that I (finally, painfully) have tracked down.
I've got a driver in smartthings I've been trying to port for a long time, recently I dramatically improved my development environment (using vs-code with auto-uploading) so I've been porting my old smartthings code over.
Anyway I've tracked down an problem with asynchttpPost (possibly others also but only tested asynchttpPost) if you see a user-agent.
Below is a bit of code that only works if you remove the 'user-agent' portion. If user-agent is set then you get a 408 error but if you remove the user-agent then it completes successfully.
This examples uses the excellent postman-echo service to just echo back your response and only works, as I mentioned, if you remove the User-Agent from the header string (which I think should be allowed?)
/*
Duplicate the curl below
curl --location --request POST 'https://postman-echo.com/post' \
--data 'foo1=bar1' \
--data 'foo2=bar2'
*/
def _privateAsyncTest() {
log.debug "_privateAsyncTest"
def params = [
uri : 'https://postman-echo.com/post',
timeout : 100,
contentType: 'application/json',
requestContentType: 'application/json',
'User-Agent' : 'dd',
body : [
"foo" : "bar",
"foo1" : "bar1",
]
]
try {
asynchttpPost("private_handler", params,params)
} catch (e) {
log.error "Error in asynchttpPos: $e \n $params"
}
}
def private_handler (response,data) {
if (response.hasError()) {
log.debug "private-handler raw error response: $response.errorData"
log.debug "private-handler total error is $response"
log.debug response.getStatus()
log.debug "private-handler error data is $data"
} else {
log.debug "private-handler was good! $response"
}
}