469,588 Members | 2,766 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

post xml payload with urllib

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.
Aug 14 '07 #1
1 5860
On Aug 14, 11:57 am, brad <byte8b...@gmail.comwrote:
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 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by franck | last post: by
reply views Thread by Pieter Edelman | last post: by
reply views Thread by Mallya | last post: by
1 post views Thread by Wobbly Bob | last post: by
4 posts views Thread by James Johnson | last post: by
2 posts views Thread by andy | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.