Guru Guru - 5 months ago 37
Python Question

POST service parameter - FLASK

This is what i get

b'{"data": ""}'

when i print my request data from a flask POST web service.


But when i do
url = request.form.get('data', None)

I get value of



Your problem is that you sent the request as follows:

req =, data=json.dumps(payload), headers={'Content-Type': 'application/json'})

When sending json data, you should format the request in requests with the json parameter as follows:

req =, json=payload, headers={'Content-Type': 'application/json'})

Further, in your flask app, you can access submitted json data via request.json

Because the content type is application/json -- it will not appear in request.form -- Data will appear in request.form when a request is received with an appropriate content type such as multipart/form-data