Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > getting an HTTP Error 500 on a form post

Thread Tools

getting an HTTP Error 500 on a form post

Posts: n/a
I'm hoping someone here can answer my problem - I'm getting a 500
error when I run this code. What it should do is setup cookies, log
in, then post a file to a form. The problem is it throws an exception
at ClientCookie.urlopen( The webserver hosting the form
is fine, the python looks like it should work, I cant figure out how
to solve or debug this.

######### python code
# cookie handler
cookieJar = ClientCookie.CookieJar()
opener =
ClientCookie.build_opener(ClientCookie.HTTPCookieP rocessor(cookieJar))
opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
fp = ClientCookie.urlopen("")
forms = ClientForm.ParseResponse(fp)

# login
form = forms[0]
form["j_username"] = "bob" # use your userid
form["j_password"] = "1234" # use your password
fp = ClientCookie.urlopen(

# post new file
fp = ClientCookie.urlopen("")
forms = ClientForm.ParseResponse(fp)
form = forms[0]
form["reportId"] = "4239"
form.add_file(open("/home/filename.xml"), "text/plain",
request =
fp = ClientCookie.urlopen(request)

########### error
Traceback (most recent call last):
File "./", line 62, in upload_xml
fp = ClientCookie.urlopen(request)
File "/usr/lib/python2.5/site-packages/ClientCookie/", line 717, in urlopen
return, data)
File "/usr/lib/python2.5/", line 387, in open
response = meth(req, response)
File "/usr/lib/python2.5/site-packages/ClientCookie/", line 391, in http_response
"http", request, response, code, msg, hdrs)
File "/usr/lib/python2.5/", line 425, in error
return self._call_chain(*args)
File "/usr/lib/python2.5/", line 360, in _call_chain
result = func(*args)
File "/usr/lib/python2.5/", line 506, in
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error
Reply With Quote
Posts: n/a
problem solved...changes to the python code were not necessary
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
URL: 'http://localhost/WebProject1', 'HTTP/1.1 500 Server Error' larkpics ASP .Net 9 10-22-2005 11:00 AM
Post file to ASP.NET causes HTTP 500: Internal Server Error stefan ASP .Net Web Services 0 03-21-2005 11:38 AM
Getting error message 'HTTP/1.1 500 Internal Server Error' on development machine Rod ASP .Net 9 07-26-2004 04:11 PM