HTTPError... read the response body?

Wojtek Walczak gminick at bzt.bzt
Mon Mar 2 18:50:51 EST 2009


On Mon, 2 Mar 2009 14:29:12 -0800 (PST), Stuart Davenport wrote:

Hi,

> I am trying to connect to a web service but I am getting HTTP 400, I
> am not too concerned about the HTTP error - but what I'd like to know
> if there is anyway I can read the response body in the HTTP 400 or 500
> case? Does the HTTPError allow this? or the urllib2 in anyway?

HTTP error 400 means 'bad request', so it's almost certainly
your mistake.


>                         #url, body, headers
>                         rq = urllib2.Request(args[1], args[3], headers)

Is args[1] a valid URL? And are you sure that you want to send
something to the web serwer? By specifying the second argument
(args[3]) you're asking python to send HTTP "POST" request,
not "GET".

-- 
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/



More information about the Python-list mailing list