On Sep 2, 10:37 am, irum <irumrauf...@gmail.com> wrote:
> Hi,
> Thanks for your prompt reply.
> I have tried both the things but I get the same error.
> With,
> x = json.loads(p.read())
>            print x
>
> I get following error:  'HttpResponse' object has no attribute
> 'read'
> Also I get same error with, json.dumps(p.read()), and same when I use
> loads and dumps as load and dump without s.
>
> Then, I tried the other option,
>
> x = json.dump(p)
>         print x
>
> I get the following error: dump() takes at least 2 arguments (1 given)
> What would be the second argument, I googled on this but find no
> helpful tips as everything written is too complicated.
>
> And with:
>            x = json.load(p)
>            print x
>
> 'HttpResponse' object has no attribute 'read'
>
> In all the examples, p is the HttpResponse object I get.
>
> Looking forward,
> Irum

Apologies for steering you wrong - that'll teach me to post without
checking.

You're right that HttpResponse doesn't have a read() method, contrary
to what I thought. So neither of those methods will work. Instead, get
the content of the response and call loads() on that:

    json.loads(p.content)

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to