3rd party REST API requires blob type for transfer. How do I convert an Attachment into a Blob?

Todd A Carter
Tera Contributor

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

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Todd A Carter
Tera Contributor

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

Masarrat Siddi1
Kilo Guru

var gsa = new GlideSysAttachment();
//Get the raw bytes in the file
var bytesInFile = gsa.getBytes(tableName, recordID);

 

For more information refer below link

 https://community.servicenow.com/community?id=community_question&sys_id=a4f0c7a5db98dbc01dcaf3231f96...

 

https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment

 

 

Thanks!!

Todd A Carter
Tera Contributor

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.