How to send data as base64 more than 5Mb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 02:33 AM
Hi, I need more knowledge about integration I have script which encode attachment as base64 everything was fine but I need to send Attachments bigger than 5Mb so I came up with idea to use:
var toBody = new GlideRecord('sys_attachment');
toBody.get(att.u_document);// att sys_id
var StringUtil = new GlideStringUtil();
var atts = new GlideSysAttachmentInputStream(toBody.sys_id+'');
var baos = new Packages.java.io.ByteArrayOutputStream();
atts.writeTo(baos);
var bytes = baos.toByteArray();
baos.close();
var encData = StringUtil.base64Encode(bytes);
obj.body = encData;
After that script I'm configuring REST message with:
r.setStringParameterNoEscape('key' encData);
after execute I got socket error and status code 0. Any idea how to solve this?
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 02:36 AM
Hi,
Did you try to print log and check encData variable?
check these links:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
01-07-2020 02:46 AM
Hi,
Of course I did problem exist with big files they are encoded correctly but when I'm trying to execute request I got status code 0 and no response body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 02:48 AM
Hi,
Probably it means 3rd party is not able to handle the large base64encoded data.
Are you sure the key parameter holds the base64 data?
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
01-07-2020 03:11 AM
yes, I'm sure .rtf file which is about 40Mb so it end up as 40B characters maybe I can split it in several files.