how do I use the requests library to send data to an HTTP endpoint in MicroPython on an ESP8266?

Hello guys, how do I use the requests library to send data to an HTTP endpoint in MicroPython on an ESP8266? My code fails to connect.
Here's the code:
import requests

response = request.post('http://example.com/data', json={'sensor': 'value'})
print(response.text)

@Middleware & OS
Solution
Shouldn't that be
response = request.post('http://example.com/data', data={'sensor': 'value'})

i.e. data instead of json
Was this page helpful?