Basically I have this xml element (xml.etree.ElementTree) and I want to POST it to a url. Currently I\'m doing something like
xml_string = xml.etree.ElementTree
If this is your own API, I would consider POSTing as application/xml. The default is application/x-www-form-urlencoded, which is meant for HTML form data, not a single XML document.
application/xml
application/x-www-form-urlencoded
req = urllib2.Request(url=url, data=xml_string, headers={'Content-Type': 'application/xml'}) urllib2.urlopen(req)