rest - Using python 'requests' to send JSON boolean -
i've got simple question, can't figure out how it. problem have want send following payload using python , requests:
{ 'on': true }
doing this:
payload = { 'on':true } r = requests.put("http://192.168.2.196/api/newdeveloper/lights/1/state", data = payload)
doesn't work, because following error:
nameerror: name 'true' not defined
sending true 'true' not accepted server, that's not option. suggestion? thanks!
you need json encode string.
import json payload = json.dumps({"on":true})
Comments
Post a Comment