This article addresses the following two needs:
- create attachments in ServiceNow through a web service request
- determine if there are limits on attachment size while sending a large payload as an attachment
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:
- REST: https://<instance-name>/api/now/table/ecc_queue
- Headers for REST:
- Accept = application/json
- Content-Type = application/json
- JSON v2: https://<instance-name>/ecc_queue.do?JSONv2?sysparm_action=insert
- Headers for JSONv2 not required
- Use a request body of:
Business rules and sensors are defined on the ECC Queue to act on records inserted with the 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
- The size of the request body
- If the body is too big to process within the defined timeout period, the entire transaction can get canceled 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.