Create and Post XML with Python
from xml.etree import ElementTree request_xml = ElementTree.Element('request') update_request = ElementTree.SubElement( request_xml, 'itemUpdateRequest') item = ElementTree.SubElement(update_request, 'item') ElementTree.SubElement(item, 'itemUrl').text = itemUrl for key, value in updateData.items():
ElementTree.SubElement(item, key).text = value response = self.request( '/es/1.0/item/update', method='post', headers={'Content-Type': 'application/xml'}, data=ElementTree.tostring( request_xml, encoding='utf-8', xml_declaration=True) )
Comments