How to send attachment files in base64 format?

Sri56
Tera Contributor

Hi All,

We have integrated servicenow with service grid tool for case exchange purpose.

Can anyone please help me on how to send attachment files in base64 format from servicenow.

I have tried with all possibilities.

Following is my code that i am using for payload:

var sa = new GlideSysAttachment();
var StringUtil = Packages.com.glide.util.StringUtil;
//Get the base64 encoding of the attachment
var binData = sa.getBytes(current);
var encData = GlideStringUtil.base64Encode(binData);

var s = new sn_ws.SOAPMessageV2('soap_message', 'http_method');

s.setStringParameterNoEscape('Filename', current.file_name);

s.setStringParameterNoEscape('TaskNumber', current.table_name.number);

s.setStringParameterNoEscape('Payload', encData);

 

Seems not working!!

Please can any one help?

 

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sri,

Does the 3rd party require base64encoded data?

are you sending it in proper xml tag?

Regards

Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sri,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

Vasantharajan N
Giga Sage
Giga Sage

Did you try with getContentBase64 method?

 

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_SGSA-getContentBase64_GR


Thanks & Regards,
Vasanth

It seems this function works only in scoped application.