I just want to try simple Django rest framework code, I used APIVIEW and posted data through browser.
CODE:
class GetData(APIView):
def post(self, request, format=None):
if request.method == 'POST':
item_id = request.data.get('item_id')
return Response({"return": "OK ","item_id":item_id})
else:
return Response({"return": "NOT OK "})
The above code should echo the item_id whatever i "POST"ed. but the result is always null.
POST data:
{ "item_id" : "3456787"}
result:
{"item_id":null,"return" :"OK "}
I don't understand where I went wrong. the above code works fine in my Loaclhost but does not work in production server.
application/json.Content-Type: application/json