1

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

     f = "<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <MakePaymentByServiceType xmlns="KioskSystems">
      <terminalId>1</terminalId>
      <serviceType>BBC</serviceType>
      <guid>asdfasd</guid>
      <requisite>123456</requisite>
      <amount>100</amount>
      <comission>decimal</comission>
      <user_comment>string</user_comment>
      <user_tin>string</user_tin>
      <user_address>string</user_address>
    </MakePaymentByServiceType>
  </soap:Body>
</soap:Envelope>"
    soup = BeautifulSoup(f, "xml")
    xml = soup.prettify()

    requests.post(url, data=xml)

response from server:

415

i also tried code like this:

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

response from server:

    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2
  • why dont you use zeep? docs.python-zeep.org/en/master Commented Nov 6, 2020 at 8:38
  • Your code does not even compile. Show the code that you are actually using. Commented Nov 6, 2020 at 8:53

1 Answer 1

3

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 = requests.post(url, headers=headers, data=xml)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.