last day (14 days later) » 

7:42 AM
0
A: No JSON object could be decoded - Django request.body

Adil MalikI guess, You are using django-rest-framework. So, You don't have to do json.loads(), becasue django-rest-framework provides request.data for POST requests and request.query_params for GET requests, already parsed in json format. So I think this should work for you. @api_view(['POST']) def comm...

 
It works for local but whenever i posted it on server it dont works.
 
is it working ? @Teekam
is it giving any errors ? @Teekam
 
It show below error TypeError at /service/comment_post/369 int() argument must be a string or a number, not 'NoneType' Request Method: POST Request URL: dev.newskhabari.com/service/comment_post/369 Django Version: 1.9.5 Exception Type: TypeError Exception Value: int() argument must be a string or a number, not 'NoneType' Exception Location: /var/www/vhosts/newskhabari.com/newskhabari_dev/app/mediapu‌​blisher/apps/media‌​pu‌​blisher/views/restVi‌​ews/restViews.py in comment_post, line 167
 
try to print request.data @Teekam and see in logs
 
in request.data it gives { "comment_description":"yyyy", "like_count": "1", "user_name":"ooo", "user_email_id":"iiii@webmail.com", "parent_comment":"1" } as i posted for it
 
7:42 AM
hy
we should talk here now
So I accessed your link
and tried to test the api
here is the post data that i passed to your url
{
"comment_description":"blah blah",
"like_count":4,
"user_name":"hello",
"user_email_id":"hello@gmail.com",
"parent_comment":"blah blah"
}
And it now giving me error on comentNews.save()
 
what type of error it is showing?
 
ValueError at /service/comment_post/369
invalid literal for int() with base 10: 'blah blah'
Yes and it is giving me success on
"comment_description":"blah blah",
"like_count":4,
"user_name":"hello",
"user_email_id":"hello@gmail.com",
"parent_comment":12
}
I hope that helped you
SO plz accept my answer and upvote it
Use pure integer like 12 where server is accepting a integer ... don't use like "12"
in the json body
 
Is it showing you success?
 
yes
 
It is stil not giving me success
 
7:55 AM
look at this image
Don't user "like_count":"4"
INstead use this "like_count":4
that's it
 
Yes i am doing , but still not get success
 
Its the same server
I don't get it
you must check everything very carefully
 
Above is my request and response
 
on what line ??
 
    commentNews.like_count = int(request.data.get('like_count'))
Its working on your side but on my end it gives error
 
8:09 AM
Yes its strange
But there must be some issue ... I hope you will find it
Plz if you got some time .. then plz upvote my one or two answers
and this one too
but not more than 3 :D
Bcz these day i am totally working to imrove my reputation
Thanks
 
ok
 

last day (14 days later) »