Forum Discussion

akashbam's avatar
New Contributor
3 years ago

How to upload a file via SOAP, as an attachment using python zeep

Hi folks,

I am trying to attach a log.txt file with my createAttachment web service. I am using zeep as a client to do so but unable to do.
I tried the same using MIME but unable to do so.


import requests
url = "WSDL url"
payload = '''<?xml version="1.0" encoding="utf-8"?>
         <description>Testing to attach document to change order</description>

headers = {
  'Content-Type': 'text/xml; charset=utf-8',
  'soapAction': 'application/soap+xml'
response = requests.request("POST", url, headers=headers, data={'data' : payload}, files=files)

3 Replies

    • akashbam's avatar
      New Contributor

      Thanks richie for your response.


      Well, I want to attach a file with code(python). I am calling soap API and binding it with with web service(createAttachment) which accepts parameter as 

      import zeep
      client.service.createAttachment(sid=788139782, repositoryHandle='doc:1002', objectHandle='cr:1306591599', description='Test file', fileName='Test Data')
      I'm able to attach a file using soapUI but want to do the same using python.