How to receive json data using HTTP POST request in Django 1.6? How to receive json data using HTTP POST request in Django 1.6? python python

How to receive json data using HTTP POST request in Django 1.6?


You're confusing form-encoded and JSON data here. request.POST['foo'] is for form-encoded data. You are posting raw JSON, so you should use request.body.

received_json_data=json.loads(request.body)


For python3 you have to decode body first:

received_json_data = json.loads(request.body.decode("utf-8"))


Create a form with data as field of type CharField or TextField and validate the passed data. Similar SO Question