asyncHttpPost vs httpPost

When trying to do asyncHttpPost I get responsecode 408. But using the same params but in a httpPost instead it works. What am I doing wrong?

	    def postParams = [
            uri: "https://api.tibber.com/v1-beta/gql",
            headers: ["Content-Type": "application/json;charset=UTF-8" , "Authorization": "Bearer $tibber_apikey"],
            body: graphQLApiQuery()
        ]
        

This works:

	    httpPostJson(postParams) { resp ->
                if(resp.status == 200){
                    log.debug "${resp.data}"
		}
	    }

But this returns 408:

asynchttpPost('myCallbackMethod', postParams)

Callback function:

def myCallbackMethod(response, data)
{
    log.debug("response.status = ${response.status}")
    if(!response.hasError())
    {
        log.debug("response.getData() = ${response.getData()}")
    }    
}

I use this successfully:

   asynchttpGet("getHumidStatusHandler", params)
}

def getHumidStatusHandler(resp, data) {
	if (resp.getStatus() == 200 || resp.getStatus() == 207) {

I found it. I had contentType in the wrong place. Also added requestContentType.

	    def postParams = [
            uri: "https://api.tibber.com/v1-beta/gql",
	    contentType: "application/json",
	    requestContentType: "application/json",
            headers: [ "Authorization": "Bearer $tibber_apikey"],
            body: graphQLApiQuery()
        ]
1 Like