Skip to content

Instantly share code, notes, and snippets.

@dwblair

dwblair/putdata.py

Created Oct 29, 2020
Embed
What would you like to do?
import requests
baseurl='http://157.230.188.100:3000/api/drives/'
public_key='c5d1df56d250615bfd3cc547d3bb7313ea1304d280efdefb9f26b268414d141c'
private_key='e18cdb6163d36b3195d17eace02932eba57314809149975fd028053feca86c02'
url = baseurl+public_key
temp = 23
humid = 31
deviceId = "sensor1"
payload = {"deviceId":deviceId,"fields":{"temp":temp, "humid":humid}}
headers = {
'Authorization': '{}'.format(private_key),
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, json = payload)
print(response.text.encode('utf8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment