Using python 'requests' to send JSON boolean
should be {'on': True}, capital T
Starting from requests 2.4.2, instead of passing in the payload with the data
parameter, you can use the json
parameter like this:
payload = {'on': True}
requests.put(url, json=payload)
And the request will be formatted correctly as a json payload (i.e. {'on': true}
).
You need to json encode it to get it to a string.
import json
payload = json.dumps({"on":True})