Building a custom REST API for attachments between ServiceNow instances with 1GB transfer capability
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 09:31 AM
Our organization has a need to create a custom REST API for inserting/deleting attachments. Upon completing this API we noticed some file size limitations that did not match the core - out of box attachment API file size capability. Essentially we need to know how we can leverage the size limitations available from default attachment API within our custom code. Our first limitation came when we were using the .getbytes() method prior to sending attachment content, being no more than 5MB. Upon changing this to GlideSysAttachmentInputStream() we reached the ceiling of 10MB between instances until we changed the appropriate system properties to extend this file size. Now we are running into an error in our outbound logs of "string object would exceed maximum permitted size of 33554432" I have seen some conflicting posts that this is and is not modifiable via a system property.
What is the maximum size ceiling for attachments transferrable via REST, and how can we leverage this via our API? Thank you in advance for any help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 01:52 PM
Hi, I think the max payload size is 25mb
Controlling maximum request size (servicenow.com)
If this integration is between ServiceNow instances, then perhaps the simplest solution would be to post the existing attachment record from sys_attachment and it's 'chunks' from sys_attachment_doc using OOB table API.
That way regardless of the attachment size, it is already broken into 4k chunks that the platform understands, without any additional work required.
Administering attachments (servicenow.com)
So all you need to do is post/insert the sys_attachment record, then the sys_attachment_doc 'chunks' that make up the attachment.