Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 111692

RESTFul API Data Shoud be Valid JSON

$
0
0

I am trying to call a service from a python script but when I try to run it a get {“message”: “Data should be valid JSON.”} here is my code

url = "http://homeassistant.local:8123/api/services/light/turn_on"
headers = {
    "Authorization": "Bearer auth_token",
    "content-type": "application/json",
}
data = {
    "entity_id": "light.shelf_light_strip",
}

response = requests.post(url, headers=headers, data=body)
print(response.text)

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 111692


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>