how to post xml in python

Tags: , ,

i am trying to post string as xml, here is the code:

     f = "<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <MakePaymentByServiceType xmlns="KioskSystems">
    soup = BeautifulSoup(f, "xml")
    xml = soup.prettify(), data=xml)

response from server:


i also tried code like this:

        with open('xmlfile.xml') as xml:
            r =, data=xml)

response from server:

    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))


HTTP 415 is Unsupported Media Type – this suggest your request is missing or has incorrect Content-Type header. Try:

headers = {"Content-Type":"text/xml"}
r =, headers=headers, data=xml)

Source: stackoverflow