I'm trying to pass JSON directly in a URL to communicate with the Ecobe API. No matter how I try to format the data, it gets escaped in the URL. Requests used to allow you to pass a config parameter in the call and that had an option to shut off encoding, but it has been removed (so the answer in this thread no longer works). The only reference I can see in the docs is to something in requests.defaults but I can't figure out how to set that. Because of this, my URL has all the JSON formatting URL-escaped instead of looking like what the API wants:
GET https://api.ecobee.com/1/runtimeReport?format=json&body={"startDate": "2010-01-01","endDate": "2010-01-02","columns": "zoneHVACmode,zoneCalendarEvent","selection":{"selectionType":"thermostats","selectionMatch": 123456789012"}}
Additionally, I've tried enough shotgun approaches (including the one in this thread) I'm not sure what's the best/ most efficient way to do this if it did work, so here's (an abbreviated version of) my current code in case there's a better option:
self.api_url = 'https://api.ecobee.com/%s?format=json&%s'
data = {
'startDate': start_date.strftime('%Y-%m-%d'),
'endDate': end_date.strftime('%Y-%m-%d'),
'columns': 'auxHeat1,compCool1,outdoorHumidity,zoneAveTemp,zoneCoolTemp,zoneHeatTemp',
'includeSensors': 'true',
'selection': self.selection_info
}
endpoint = 'runtimeReport'
params_json = simplejson.dumps(params)
response = requests.get(self.api_url % (endpoint, params_json), headers=self._get_headers())