I'm hoping to get a bit of help. I have some working code written in Python3 which works great on a windows PC and a Raspberry Pi 3. I'd like to use micropython on an ESP8266 instead. The code is making an http POST request to an ArcGIS Rest API. For some reason the API does not like the json body when sent via urequests. Again, this same request is properly received when using Python3 requests lib. It's not an internet connection issue, I did not include it in the code below but I do connect to the internet just fine. The API does return a response, but it is not the desired response like the Python3 code does. The API should be making a data update and return json indicating a successful update, instead I get the html from the url as though the data sent was never posted to the form.
Thanks in advance for any help on this!
Code: Select all
#Working Python3 code
import requests
url = 'https://services9.arcgis.com/jyf59MjuiWfY46oy/arcgis/rest/services/IOT/FeatureServer/0/updateFeatures'
data = {
'f': 'json',
'features': "[{'attributes': {'objectid': '1','READ_VALUE': '13'}}]"
}
x = requests.post(url,data)
print(x.text)
Code: Select all
#micropython code (not working)
#code after connecting to internet
import urequests
url = 'https://services9.arcgis.com/jyf59MjuiWfY46oy/arcgis/rest/services/IOT/FeatureServer/0/updateFeatures'
data = {
'f': 'json',
'features': "[{'attributes': {'objectid': '1','READ_VALUE': '13'}}]"
}
x = urequests.post(url,json=data)
print (x.text)