3rd party REST API requires blob type for transfer. How do I convert an Attachment into a Blob?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2019 12:58 PM
Using an include script, I'm unable to reference the Blob library, atob, etc.
Evaluator: org.mozilla.javascript.EcmaError: "Blob" is not defined. Caused by error in script at line 1 ==> 1: var blob = new Blob();
So, how do I take an attachment and turn it into a blob?
BTW, I need to do the opposite as well. Downloaded blob turned into an attachment.
TIA
Todd
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2019 09:37 PM
Hi Todd,
you need to send attachments to 3rd party?
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
09-26-2019 05:34 AM
Yes. The third party is Concord Contract Management. You can see their documentation
at https://concordapi.docs.apiary.io/#introduction/overview
You can probably request a concord account on their uat box if you'd like to play with it. Unfortunately, the payload in the body is not a 64bit encoded string, but a blob.
I'm using the Upload Version from PDF API using multipart/form-data. I've gotten all the formatting worked out, just can't figure out how to make a blob from an attachment. The tools do not appear to be available in ServiceNow.
Thank you, Ankur for responding.
Todd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2019 06:12 AM
var gsa = new GlideSysAttachment();
//Get the raw bytes in the file
var bytesInFile = gsa.getBytes(tableName, recordID);
For more information refer below link
https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2019 07:06 PM
At this point, we have abandoned the interface requirement to pass the document content. Someone is doing it manually. So, no answers. Thanks for trying.