nkgilley / python-ecobee-api

Python API for controlling Ecobee Thermostats
MIT License
44 stars 40 forks source link

Pass request body with json parameter and do not re-encode json string #34

Closed katiekecobee closed 6 years ago

katiekecobee commented 6 years ago

On each recursive call of make_request, json.dumps is called on body. This results in a string that is already json encoded being re-encoded. Everytime this happens back slashes are escaped again creating invalid requests: (try: json.dumps(json.dumps(json.dumps('\\'))) for an example of whats going on).

Requests has specific support for json encoded body by using json= instead of data= when making a post request. This avoids the need to encode and I think is the easiest way to solve this issue.

nkgilley commented 6 years ago

Thanks @katiekecobee! 👍

https://pypi.org/project/python-ecobee-api/0.0.19/