- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2021 08:33 AM
Hi Experts,
Recently I have developed a scripted REST API for one of our customer. This API sends a response to the Document Requests made on the customers third party portal, the response contains base64 of files that are requested.
Sending files upto 10MB does not create a problem, however when file size exceeds 10MB HTTP error code 500 is returned as response.
As suggested by some of the community posts and knowledge articles, I created following system properties to surpass this limit, but it did not work.
1) glide.rest.max_content_length
2) glide.http.outbound.max_timeout
Below is the script I have used to encode the file-
var StringUtil = new GlideStringUtil();
var gsis = GlideSysAttachmentInputStream(SYS_ID OF ATTACHMENT RECORD);
var ba = new Packages.java.io.ByteArrayOutputStream();
gsis.writeTo(ba, 0, 0);
documentObj.base64EncodedData = StringUtil.base64Encode(ba.toByteArray());
documentObj.fileName = documentAttachment.file_name.toString();
documentObj.fileType = documentAttachment.content_type.toString();
var size_bytes = parseInt(documentAttachment.size_bytes);
var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var MB = (size_bytes / Math.pow(1024, 2)).toFixed(2) * 1 + ' ' + sizes[2];
documentObj.documentSize = MB;
}
}
var parser = new JSON();
var str = parser.encode(documentObj);
return str;
If I run this function in background script, following error is encountered-
I would like to ask few questions in this context-
Question 1: Is it a restriction from REST that I am not able to send large files? Or it is because of the String Object size that is getting exceeded?
Question 2: Is there a way by which File getting sent can be compressed under 10 MB and sent? I tried to compress a PDF file of 18MB manually but its size got reduced to 15MB only, so not sure compression would work.
Question 3: Can the file be broken into small chunks and then encoded and sent back as response? If yes, please let me know the script that would help.
Question 4: Is there any other way to achieve this requirement?
Thank you for reading this post. Please provide your inputs at the earliest.
Thank you
Astha Chaubey
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2021 09:21 AM
Hi,
yes there is a limit
increase the system property
glide.size.aware.max_size.org.mozilla.javascript.NativeString -> 83886080
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2021 10:23 AM
Hi Ankur,
Thanks for sharing this doc link.
These seem to be properties for inbound requests, but my case is for outbound. Anyway I think page not becoming responsive is an issue of Postman app and we can do nothing about it.
Below is a link that clarifies it.
https://github.com/postmanlabs/postman-app-support/issues/4551
I will get this tested by client and will see if they face a lot of delay or timeout.
Thanks for all the help!
Astha Chaubey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:31 AM
Hi Ankur , Kindly help me .https://www.servicenow.com/community/itsm-forum/how-to-solve-this-error-quot-maximum-permitted-size-...
I am not getting "glide.size.aware.max_size.org.mozilla.javascript.NativeString -> 83886080" in system property. my instance is in tokyo version
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 07:29 AM
did you try creating a fresh system property in your instance with that value?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 10:38 PM
Only i need to create that sytem property it will stop giving error like "
exceed maximum permitted size of 33554432
"please reply . thanks for the previous reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 10:54 PM
yes please try that
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader