Skip to content

Example of using zeep with attach #1

@rainierpineda2

Description

@rainierpineda2

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions