Issue
I have a django method and I'm just trying to pull out a POST variable:
@csrf_exempt
def update_backer(request):
for k, v in request.POST.items():
print(k, v)
email = request.POST.get("email", "none")
return JsonResponse({"data":{
"email":email
}})
When I try to do a POST via javascript XMLHttpRequest, I wasn't getting the data through. So I fell back to Postman to try to confirm things are working on the django end. And I am posting the data, but django isn't seeing it. Am I doing something obviously wrong?
Edit: Interestingly enough, if I change it to GET instead of POST, it works as I would expect.
Solution
For POST
request values are sent in request body
. You can use application/x-www-form-urlencoded
content type so that request body has same format of query params.
Answered By - user8193706
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.