Attachments to base64

harshi_ramesh
Tera Expert

Hi people

 

Need a solution regarding how we can convert attachments to base64 and sent it via API.

So, basically I have created a catalog and have been sending the info added onto the fields from the catalog via API to 3rd party(all this done using flow).

 

  • Now, I need to send the attachments as well through the same API trigger. Currently I have been using "LookUp Record" step, attaching screenshot. 
  • But the issue is, say we have 2 attachments, the payload goes twice. As we have "For Each", but I need it to be sent in one trigger. Something like this:
<attachments>
<z_attachment>
<base64>{base64_value}</base64>
</z_attachment>
<z_attachment>
<base64>{base64_value}</base64>
</z_attachment>
</attachments>
  • I was able to sent 'hash value', but need to send as base64. How?

 

I would appreciate your help!! Let me know if further details are required.

 

Thanks

1 ACCEPTED SOLUTION

@harshi_ramesh 

then here is the alternative for scoped app

var gr = new GlideRecord('sys_attachment');
gr.get('3fd6017407d3dc50540bf2508c1ed027');

var sysAtt = new GlideSysAttachment();

var base64Data = sysAtt.getContentBase64(gr);

gs.info(base64Data);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

5 REPLIES 5

@harshi_ramesh 

then here is the alternative for scoped app

var gr = new GlideRecord('sys_attachment');
gr.get('3fd6017407d3dc50540bf2508c1ed027');

var sysAtt = new GlideSysAttachment();

var base64Data = sysAtt.getContentBase64(gr);

gs.info(base64Data);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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