Attachment API calls
IMPORTANT The SOAP API entered a limited enhancement phase in Q4 2020. Access to version 1.6 will eventually be deactivated. At this time, there is no end-of-lifecycle date.
The following three API calls, GetAttachment(), CreateAttachment(), and DeleteAttachment() are specific to working with attachments in the API. Attachments are external documents that are associated with an Autotask entity. Refer to AttachmentInfo (SOAP API) to learn more about attachments.
Use these three API calls along with the entity to create and manage attachments. Attachments do not use the standard create() and update() API calls.
You can use query() on the AttachmentInfo entity to determine the AttachmentId for a specific attachment.
CreateAttachment()
Use the CreateAttachment() API call to add an attachment to an account, ticket, project, or opportunity. The attachment can be a specific document uploaded to the Autotask server, a link to a file, a link to a folder, or a URL.
-
When adding an attachment to an entity's Data field, the attachment must be encoded as base64 binary data.
- To create an attachment via the API you must specify the type "attachment" as shown in the NEW sample code below, otherwise the call will fail.
- The maximum attachment file size indicated in the Autotask Online Help does not apply to the API. The API size limit for individual attachment files is 6 to 7 MB, with a maximum of 10,000,000 bytes within a five-minute period. If your integration exceeds either of these limits, you'll receive an error message indicating condition. If the integration exceeds 10,000,000 bytes within a five-minute span, the API will also stop accepting attachment creation calls for five minutes.
- Attachment types are limited to the file types allowed in Autotask. For more details, refer to Add attachments.
NOTE The API size limit for individual attachments is less than the 10 MB limit for individual attachment files when working through the Autotask UI.
Sample code CreateAttachment ()
SOAP XML:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<AutotaskIntegrations xmlns="http://autotask.net/ATWS/v1_6/">
<IntegrationCode>[insert your own tracking identifier]</IntegrationCode>
</AutotaskIntegrations>
</soap:Header>
<soap:Body>
<CreateAttachment xmlns="http://autotask.net/ATWS/v1_6/">
<attachment>
<Info>
<FullPath xsi:type="xsd:string">C:\Users\dloveland\Downloads\Test.docx</FullPath>
<ParentID xsi:type="xsd:string">28795</ParentID>
<ParentType xsi:type="xsd:string">4</ParentType>
<Publish xsi:type="xsd:string">2</Publish>
<Title xsi:type="xsd:string">Ticket Requirements Document</Title>
<Type xsi:type="xsd:string">FILE_ATTACHMENT</Type>
</Info>
<Data>Insert your attachment byte array data here</Data>
</attachment>
</CreateAttachment>
</soap:Body>
</soap:Envelope>
Sample C# Code:
// Create an attachment.
TestAPI.AutotaskAPI.AttachmentInfo attachmentInfo = new TestAPI.AutotaskAPI.AttachmentInfo
{
Type = "FILE_ATTACHMENT", // File attachment type
FullPath = attachmentFilePath, // File path string
ParentType = 4, // Ticket parent type
Publish = 2, // Internal Users Only
Title = "Ticket Requirements Document",
ParentID = 28795 // Parent entity id (Ticket ID)
};
TestAPI.AutotaskAPI.Attachment attachment = new TestAPI.AutotaskAPI.Attachment
{
Info = attachmentInfo
};
if (attachmentInfo.Type.ToString() == "FILE_ATTACHMENT")
{
attachment.Data = System.IO.File.ReadAllBytes(attachmentFilePath);
}
apiService.CreateAttachment(integration15, attachment);
GetAttachment()
Use query() to determine the attachmentId. Then use the GetAttachment() API call to get attachment information from Autotask. Finally, add the necessary SOAP XML to download the attachment to Autotask. See the sample SOAP XML below.
NOTE To correct a defect, the GetAttachment call now returns only the attachment filename and extension for Autotask attachments. This change does not apply to Client Access Portal attachments.
Sample GetAttachment()
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<AutotaskIntegrations xmlns="http://autotask.net/ATWS/v1_6/">
<IntegrationCode>[insert your own tracking identifier]</IntegrationCode>
</AutotaskIntegrations>
</soap:Header>
<soap:Body>
<GetAttachment xmlns="http://autotask.net/ATWS/v1_6/">
<attachmentId>3554</attachmentId>
</GetAttachment>
</soap:Body>
</soap:Envelope>
DeleteAttachment()
Use the DeleteAttachment() API call to delete an attachment from an account, ticket, project, or opportunity entity. Use query() to determine the attachmentId.
Sample DeleteAttachment() SOAP XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<IntegrationCode>[insert your own tracking identifier]</IntegrationCode>
</AutotaskIntegrations>
</soap:Header>
<soap:Body>
<DeleteAttachment xmlns="http://autotask.net/ATWS/v1_6/">
<attachmentId>702</attachmentId>
</DeleteAttachment >
</soap:Body>
</soap:Envelope>