post xml payload with urllib

Discussion in 'Python' started by brad, Aug 14, 2007.

  1. brad

    brad Guest

    Has anyone sent an xml payload via post using urllib? I'd like to do
    something like this:

    logon_request = """<LoginRequest>
    <password>"the_password"</password>
    <user>"the_user"</user>
    </LoginRequest>"""

    logon = urllib.urlopen("https://127.0.0.1/api/version/xml", logon_request)
    print logon.read()
    logon.close()

    127.0.0.1 expects xml via a https connection post.
     
    brad, Aug 14, 2007
    #1
    1. Advertising

  2. brad

    Guest

    On Aug 14, 11:57 am, brad <> wrote:
    > Has anyone sent an xml payload via post using urllib?


    Haven't used urllib, but have used urllib2 to do a POST.

    Might something like this work...

    import urllib2

    logon_request = """<LoginRequest>
    <password>"the_password"</password>
    <user>"the_user"</user>
    </LoginRequest>"""

    req = urllib2.Request("https://127.0.0.1/api/version/xml",
    data=logon_request)
    openObj = urllib2.urlopen(req)
    response = openObj.read()
     
    , Aug 14, 2007
    #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. Jonathan Gardner

    Asynchronous urllib (urllib+asyncore)?

    Jonathan Gardner, Feb 26, 2008, in forum: Python
    Replies:
    1
    Views:
    473
    Terry Jones
    Feb 27, 2008
  2. Ravi

    XML payload

    Ravi, Jun 4, 2009, in forum: XML
    Replies:
    1
    Views:
    2,327
  3. Chris McDonald
    Replies:
    0
    Views:
    293
    Chris McDonald
    Nov 1, 2010
  4. KC

    SchemaLocation within Xml payload and WSDL.exe

    KC, Aug 27, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    237
  5. Old Man

    xml payload to webservice

    Old Man, Sep 15, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    328
    Girish Bharadwaj
    Sep 16, 2004
Loading...

Share This Page