Blank payload when sending POST via Micropython #10774
Unanswered
rishikul030788
asked this question in
ESP32
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question -
I want to call POST from micropython to Django webserver. The POST payload shows up as empty when called from the micropython code. When the same code is ran with C-Python, it does show up with the filled payload.
Here is the micropython code -
import urequests as requests
url = "http://192.168.0.33:8000/species/"
payload={'name': 'test12',
'classification': 'sheep12',
'language': 'sheep_lang12'}
files=[
]
headers = { 'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.request("POST", url, headers=headers, data=payload)
print('success')
print(response.text)
The output of response.txt is - {'name':'',classification:'',language:''}
I also tried using an alternative of the payload to use JSON. Here is the JSON payload attempt
import urequests as requests
import ujson as json
url = "http://192.168.0.33:8000/species/"
payload={'name': 'test12',
'classification': 'sheep12',
'language': 'sheep_lang12'}
files=[
]
headers = { 'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
print('success')
print(response.text)
What did I miss here ?
Beta Was this translation helpful? Give feedback.
All reactions