What is the actual content of request.body? (as in, "print request.body")To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei1Sdb_QGG3hxixj2RNqiqaafjQMkwqGkpokXqcCOGgejA%40mail.gmail.com.--On Sun, Jun 21, 2015 at 9:26 AM, Dhaval M <dhaval0003@gmail.com> wrote:Thank you in advance for any help (this is my first post to this community)--I am using Django as my application server for my project. I am new to web development so please pardon and feel free to correct me for any mistake.I am running simple, client server combination where from client I am trying to send JSON data and on the server I am trying to parse it.SERVER CODE:def addPatient(request):
if request.method == 'POST':
# Convert JSON to python objects and
# store into the DB
recJSON = json.loads(request.body)
#logger.debug("%s",recJSON['SenderID'])
logger.debug("%s",request.body)
#print 'Raw Json "%s"' % request.body
return HttpResponse(json.dumps(request.body),content_type="application/json")
But getting an error at json.loads. ValueError: No JSON object could be decoded
Also I would appreciate if any one can direct me to good tutorial on Django (I already read http://www.djangobook.com/)
I dont know where and what I am doing wrong. I checked the client side message and it is JSON used http://jsonlint.com/ to validate it is JSON data.
Thank you once again.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5bc51870-6b56-456f-bc6d-18cf20487265%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB%2BAj0sUoKrU%2BGYBij8hnbMNkggdJFUBsYm9GNvZ%3D3nUc89B0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment