MattParr / python-atws

Autotask Web Services python module
MIT License
32 stars 10 forks source link

CreateAttachment is returning an empty byte array #82

Open cyclops26 opened 4 years ago

cyclops26 commented 4 years ago

@natchu - hoping you can provide insight on how you got this functional.

Currently, I'm doing the following and receiving no errors, just an empty byte response from AutoTask and the attachment never shows up on the ticket.

suds_client is a connection to my v1.6 endpoint for my zone autotask_connection is my atws autotask connection

attachment_object = self.suds_client.factory.create('Attachment')
attachment_object.Data = open('/tmp/testfile.txt', 'rb').read()
attachment_object.Info.ParentID = 28512 # ticket to update
attachment_object.Info.ParentType = 4 # ticket type
attachment_object.Info.Type = "FILE_ATTACHMENT"
attachment_object.Info.Title = "Ticket Test"
attachment_object.Info.FullPath = "/tmp/testfile.txt"
attachment_object.Info.Publish = 2 # internal users
attachment_object.Info.ContentType = "text/plain"
autotask.CreateAttachment(attachment_object)

Using a SOAP Logging Plugin with atws connection - this is the XML that is generated and sent to AT:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://autotask.net/ATWS/v1_6/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Header>
      <AutotaskIntegrations xmlns="http://autotask.net/ATWS/v1_6/">
         <IntegrationCode>SCRUBBED-INTEGRATION-CODE</IntegrationCode>
      </AutotaskIntegrations>
   </SOAP-ENV:Header>
   <ns0:Body>
      <ns1:CreateAttachment>
         <ns1:attachment>
            <ns1:Data>b'TEST\\n'</ns1:Data>
            <ns1:Info>
               <ns1:id />
               <ns1:ParentID>28512</ns1:ParentID>
               <ns1:ParentType>4</ns1:ParentType>
               <ns1:Type>FILE_ATTACHMENT</ns1:Type>
               <ns1:Title>Ticket Test</ns1:Title>
               <ns1:FullPath>/tmp/testfile.txt</ns1:FullPath>
               <ns1:Publish>2</ns1:Publish>
            </ns1:Info>
         </ns1:attachment>
      </ns1:CreateAttachment>
   </ns0:Body>
</SOAP-ENV:Envelope>

I receive this response back b''

Originally posted by @natchu in https://github.com/MattParr/python-atws/issues/65#issuecomment-506579748