getting an HTTP Error 500 on a form post

Discussion in 'Python' started by iBlaine, Jun 4, 2008.

  1. iBlaine

    iBlaine Guest

    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(form.click()). 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.HTTPCookieProcessor(cookieJar))
    opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
    ClientCookie.install_opener(opener)
    fp = ClientCookie.urlopen("http://example.com/login.user")
    forms = ClientForm.ParseResponse(fp)
    fp.close()

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

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

    ########### error
    Traceback (most recent call last):
    File "./old-import-xml.py", line 62, in upload_xml
    fp = ClientCookie.urlopen(request)
    File "/usr/lib/python2.5/site-packages/ClientCookie/
    _urllib2_support.py", line 717, in urlopen
    return _opener.open(url, data)
    File "/usr/lib/python2.5/urllib2.py", line 387, in open
    response = meth(req, response)
    File "/usr/lib/python2.5/site-packages/ClientCookie/
    _urllib2_support.py", line 391, in http_response
    "http", request, response, code, msg, hdrs)
    File "/usr/lib/python2.5/urllib2.py", line 425, in error
    return self._call_chain(*args)
    File "/usr/lib/python2.5/urllib2.py", line 360, in _call_chain
    result = func(*args)
    File "/usr/lib/python2.5/urllib2.py", line 506, in
    http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 500: Internal Server Error
    iBlaine, Jun 4, 2008
    #1
    1. Advertising

  2. iBlaine

    iBlaine Guest

    problem solved...changes to the python code were not necessary
    iBlaine, Jun 4, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rod
    Replies:
    9
    Views:
    3,726
    Jim Cheshire [MSFT]
    Jul 26, 2004
  2. NNTP
    Replies:
    2
    Views:
    970
    =?Utf-8?B?S2V2aW4gVG9kZA==?=
    Mar 18, 2005
  3. larkpics
    Replies:
    9
    Views:
    8,979
    Patrick.O.Ige
    Oct 22, 2005
  4. stefan
    Replies:
    0
    Views:
    162
    stefan
    Mar 21, 2005
  5. Kashif

    getting a http 1.1 500 internal server error message

    Kashif, Feb 28, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    117
    Kashif
    Feb 28, 2006
Loading...

Share This Page