I am trying to upload data to Adafruit.io using post method of urequests library. I have tried to options. I both I have ensured I am connected to wifi. The first method is this:
Code: Select all
import urequests as requests
import json
url = "https://io.adafruit.com/api/v2/username/feeds/battery/data?X-AIO-Key=XXXXXXX"
data = {
"value": "88"
}
r = requests.post(url, data=data)
results = r.json()
print (results)
The second option is the following:TypeError: object with buffer protocol required
Code: Select all
import urequests as requests
import json
import ujson
url = "https://io.adafruit.com/api/v2/andermutu99/feeds/battery/data?X-AIO-Key=3fe2f3eb5e694346b3f9e709b3128182"
data = {
"value": "88"
}
data = ujson.dumps(data)
r = requests.post(url, data=data)
results = r.json()
print (results)
The first method works perfectly in my PC running in Python 2.7.{'error': 'request failed - failed to save data to feed battery. param is missing or the value is empty: datum'}
Please any help or suggestion is highly appreciated.
Thanks a lot,
Ander.