Skip to content

Instantly share code, notes, and snippets.

@dwblair
Created October 29, 2020 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwblair/8a40ed1663c0a6b374192dab44e289f8 to your computer and use it in GitHub Desktop.
Save dwblair/8a40ed1663c0a6b374192dab44e289f8 to your computer and use it in GitHub Desktop.
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