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... 