remaudcorentin-dev / python-zeep-adv

Extended python-zeep to manage mtom multipart attachments with mime types (windows oriented - cp1252 encoding)
Other
0 stars 1 forks source link

Example of using zeep with attach #1

Open rainierpineda2 opened 4 years ago

rainierpineda2 commented 4 years ago

Hello,

Can you please provide me with an example of using zeep-adv with an attached file. Here is an example of what I've tried and it's not working for me...

    def __init__(self, wsdl=WSDL):
        self.wsdl = wsdl
        self.client = Client(self.wsdl, transport=TransportWithAttach())

    def attach_file_to_chg(self, session_id, chghandle, filename):
        '''
        Attach/upload file to the change order given the 
        change order handle and repository handle
        '''
        try:
            self.client.type_factory("ns0")
            self.client.attach(os.getcwd() + "/" + filename)
            payload = {
                'sid': session_id,
                'repositoryHandle': 'doc_rep:1002',
                'objectHandle': str(chghandle),
                'description': 'This is an attachment',
                'fileName': str(filename),
            }
            response = self.client.service.createAttachment(**payload)
            #print('response: '+str(response))
            return response
        except zeep.exceptions.Fault as e:
            raise Exception(str(e))
        except Exception as e:
            raise Exception(str(e))
aurtasun commented 7 months ago

@rainierpineda2 I have the same problem. how did you solve it?