Django get POST data posted via cURL -
i'm sending data using curl this:-
curl -x post --header "content-type: application/json" --header "accept: application/json" -d "{ \"social_id\": \"string\", \"social_source\": \"fb/gmail\", \"access_token\": \"string\" }"
but i'm not able data in views:-
here view:-
class usercreate(view): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super(usercreate, self).dispatch(request, *args, **kwargs) def post(self, request): print request.post['social_id']
i've tried request.data
well. wrong doing?
if posting json blob server not have post
parameters available - populated when submit data in application/x-www-form-urlencoded
format (e.g., using html form).
you can access json data follows (from inside view function):
import json data = json.loads(request.body) # data python dict, e.g., print data['social_id']
Comments
Post a Comment