Notifications

6744 views

Creating attachments using Web Services 

 

Overview
This article addresses the following two needs:
  • create attachments in ServiceNow through web service request
  • determine if there are limits on attachment size while sending a large payload as an attachment

 

Solution

Follow the instructions in Attachment Creator Webservice in the ServiceNow product documentation.

The article is written for SOAP web services, but the same principle can be used with either REST API or JSONv2. In those cases, send a POST request to the following URLs:

Use a request body of:

{"agent":"AttachmentCreator","topic":"AttachmentCreator","name":"<FileName>:<Format>","source":"<targetTable>:<SysId>","payload":"<base64encodedStr>"}

  

Additional information

Business rules and sensors are defined on the ECC Queue to act on records inserted with AttachmentCreator agent. Sending a request to the ECC Queue as described above through any web service creates the attachment.

Attachment creation is limited by:

  • The size of the payload field
    • The payload field can take values up to 16MB so it is usually okay to send a base64 encoded payload with a size up to 16 MB
    • If you are using SOAP to do the insert, the payload file size limitation is overridden by the glide.soapprocessor.large_field_patch_max property
  • The max attachment size property
    • To check the max attachment file size property, follow the instructions in Limiting Attachment File Size in the ServiceNow product documentation
  • The size of request body
    • If the body is too big to process within the defined timeout period, the entire transaction can get cancelled and cause a timeout response. With the out-of-box http timeout setting, an attachment with a size of 8 MB should still be attached successfully.

Article Information

Last Updated:2016-09-15 15:59:25
Published:2015-03-06