AsyncHttpPost throwing 408

Hardware version: C-7 Platform version: 2.3.9.177

Good day,

I'm having a devil of a time getting a AsyncPost to work. I keep getting a 408 exception (timeout). I believe it is due to malformed parameters. I believe the Body parameter is the culprit...because when I omit the Body parameter, the 408 goes away. I get the 408 even when the URI is an 'echo' server, which, in my mind, indicates that Hubitat is making the evaluation/exception.

Follows is a debug log dump of the parameters:
myParams: [uri:https://echo.free.beeceptor.com, headers:[Authorization:Bearer cef3f850-6eb1-407d-962e-efd1553c9461, Content-Type:application/json], body:{"requests":[{"path" : "/location" }, {"path" : "/battery" }, {"path" : "/charge" }]}]

I thought that maybe 'it' didn't like the duplicated key of "path"...I changed it to path1, path2, path3...still the 408.

I should note that the above Body parameter conforms to the 3rd party API providers specifications in terms of duplicated key values, braces, brackets, quotation marks and other punctuation - albeit the specification was in terms of a Curl template/example. I did try various permutations to no avail.

I have little doubt that I'm making a fundamental error, somewhere, but I can't see it.

Any insight or direction appreciated.

Thanks

Here's a snippet taken from my Honeywell WiFi Thermostat driver, where it connects to Honeywell's servers. It's got a lot more header values and

    def params = [
        uri: "https://${tccSite()}/portal/Device/CheckDataSession/${settings.honeywelldevice}",
        headers: [
            'Accept': '*/*', // */ comment
            'DNT': '1',
            'Cache': 'false',
            'dataType': 'json',
            'Accept-Encoding': 'plain',
            'Cache-Control': 'max-age=0',
            'Accept-Language': 'en-US,en,q=0.8',
            'Connection': 'keep-alive',
            'Referer': "https://${tccSite()}/portal",
            'X-Requested-With': 'XMLHttpRequest',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36',
            'Cookie': device.data.cookiess
        ],
	  timeout: 10
    ]

    if (debugOutput) log.debug "sending getStatus request"
    asynchttpGet("getStatusHandler", params)
}

def getStatusHandler(resp, data) 
{   
	if (resp.getStatus() == 200 || resp.getStatus() == 207)
	{
		if (debugOutput) log.debug "status = ${resp.getStatus()}"
		if (debugOutput) log.debug "data = ${resp.data}"		///
        
		// lgk error handling for bad page coming back
        
		try {
              
		      if (resp.data) {            
				def setStatusResult = parseJson(resp.data)
			
			      if (debugOutput) { 
			          log.debug "Request was successful, $resp.status"
			          log.debug "data = $setStatusResult"

And here's the POST snippet, showing the Body definition:

    def params = [
        uri: "https://${tccSite()}/portal/Device/SubmitControlScreenChanges",
        headers: [
            'Accept': 'application/json, text/javascript, */*; q=0.01', // */ comment
            'DNT': '1',
            'Accept-Encoding': 'gzip,deflate,sdch',
            'Cache-Control': 'max-age=0',
            'Accept-Language': 'en-US,en,q=0.8',
            'Connection': 'keep-alive',
            'Host': "${tccSite()}",
            'Referer': "https://${tccSite()}/portal/Device/Control/${settings.honeywelldevice}",
            'X-Requested-With': 'XMLHttpRequest',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36',
            'Cookie': device.data.cookiess
        ],
        body: [
            DeviceID: "${settings.honeywelldevice}",
            SystemSwitch: state.deviceSetting.SystemSwitch,
            HeatSetpoint: state.deviceSetting.HeatSetpoint,
            CoolSetpoint: state.deviceSetting.CoolSetpoint,
            HeatNextPeriod: state.deviceSetting.HeatNextPeriod,
            CoolNextPeriod: state.deviceSetting.CoolNextPeriod,
            StatusHeat: state.deviceSetting.StatusHeat,
            StatusCool: state.deviceSetting.StatusCool,
            fanMode: state.deviceSetting.FanMode,
            DisplayUnits: location.temperatureScale,
            TemporaryHoldUntilTime: state.deviceSetting.TemporaryHoldUntilTime,
            VacationHold: state.deviceSetting.VacationHold
        ],
	  timeout: 10
    ]

    if (debugOutput) log.debug "params = $params"

Maybe there's an idea in there for you... :slight_smile:

I appreciate your time and consideration in responding, but in review, I'd be doing a whole lotta guessing as to additional headers and their respective values.

I had dissembled my Groovy HttpPost and put it into Postman...and it works there. I noticed that Postman adds, by default(?), the parameter Content-Length in the code snippet. So, I tried adding that to my Groovy script. Regrettably, no difference. There are other headers in Postman's HTTP configuration worksheet (Connection, Accept)...maybe I'll try them, but they seem API server related.

My guide has been the API provider's template/example that references only the Authorization and Content-Type headers.

Thanks

Thanks to a years old thread (https://community.hubitat.com/t/dns-settings-where/122799/41) (go to bottom of thread), I checked and found that my Hubitat Platform version was woefully out of date. I updated and the problem is no longer.

I wish I understood the topic well enough to describe the problem and its resolution via the update, but a solution is a solution.

Thanks

1 Like