0
import urllib2
request = urllib2.Request("URL HERE", data="<port>0</port>",
                     headers={'Content-Type': 'application/xml'})
u = urllib2.urlopen(request)
response = u.read()

I tried this but found out the XML is never getting to the server. I need the XML to get to the server at the same time the HTTP request does so the proper response is sent back.

Takkun
  • 6,131
  • 16
  • 52
  • 69
  • Possible duplicate of http://stackoverflow.com/questions/3238925/python-urllib-urllib2-post Basically, from that post, what does your URL look like and is it actually hitting the correct "page" ? – Christian Witts May 23 '12 at 13:41
  • example.com/XmlApi?op=portStatus&port=0 <= This works fine, but I will need to send a large number of variables to other API methods with XML. I mean I could not use XML, and parse the incoming XML and build a big string like &port=1&blah=2&yeah=5...... – Takkun May 23 '12 at 13:47
  • Duplicate of http://stackoverflow.com/questions/10708828/how-to-fix-httplib-badstatusline-exception/10721643 ? – mata May 23 '12 at 14:06

1 Answers1

0

Perhaps this is what you are looking for: http://www.voidspace.org.uk/python/articles/urllib2.shtml#data

eomer
  • 397
  • 1
  • 3
  • 14