Help with the API
Hi,
I'm trying to chnage few things by using the API, I can connect, authenticate, get the details of the structures but I have problems in updating the structure attributes, the provided example in the doc doesnt work :
import requests url = "https://api.flair.co/api/structures/4351" payload = "{\"data\":{\"type\":\"structures\",\"attributes\":{\"active-schedule-id\":\"e569ca11-643d-499d-8090-c3e4902d1cb9\"}}}" headers= {} response = requests.request("PATCH", url, headers=headers, data = payload)
------------
I changed the structure Id to may own structure id and I tried to update the 'set-point-temperature-c' but no luck
(Also it's missing the headers for the authentication)
Every time I'm getting teh following error:
'{"errors": [{"title": "Bad Request", "status": "400", "detail": ["This request could not be processed."]}]}'
Here is my own code:
url = "https://api.flair.co/api/structures/" + id
payload = "{\"data\":{\"type\":\"structures\",\"attributes\":{\"set-point-temperature-c\":25.00}}}"
headers = { 'Content-Type': 'application/x-www-form-urlencoded','Accept': 'application/json','Authorization': 'Bearer ' + access_token }
response = requests.patch(url, headers=headers, params=payload)
print(response.text.encode('utf8'))
id contains the my strcuture id and access_token my authentication token.
Any help would be appreciated :)
Please sign in to leave a comment.
Comments
1 comment