By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

post xml payload with urllib

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.