Converting httpGet to httpClient

I'm not sure what I'm missing here while trying to convert my old httpGet() requests to the new httpClient().

Old Version

header = {'Content-Type': 'text/json','Authorization':'Bearer %s' % accessToken} 
body = '{"selection":{"selectionType":"registered","selectionMatch":"","includeRuntime":true}}' #"includeAlerts":true

url = 'https://api.ecobee.com/1/thermostat?format=json&body=%s' % body
response = system.net.httpGet(url, headerValues=header)
json = system.util.jsonDecode(response)	

Attempted new version

headers = {"Content-Type": "text/json","Authorization":"Bearer %s" % accessToken} 
params = {"selection":{"selectionType":"registered","selectionMatch":"","includeRuntime":True}} #"includeAlerts":true

url = 'https://api.ecobee.com/1/thermostat?format=json&body='
response = http.client.get(url, params = params, headers=headers)
json = response.getText()
print json

response

{
  "status": {
    "code": 4,
    "message": "Serialization error. Malformed json. Check your request and parameters are valid."
  }
}

I fixed it, I should have taken out the & between format and body and added to the dictionary and not the url. This fixed it :slight_smile:

params = {"format":"json","body":{"selection":{"selectionType":"registered","selectionMatch":"","includeRuntime":"true"}}} #"includeAlerts":true

url = 'https://api.ecobee.com/1/thermostat'
1 Like