send multiple attachments as part of REST message via flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2023 06:44 AM
Hi All,
I have a requirement to send multiple attachments from an incident record as Binary files to a 3rd party from flow designer. I am using REST message with content type as application/octet-stream. For a single file, its working fine but for multiple attachments, the response shows error invalid content type. Below is the code:
var attachments=[];
var fileName=[];
var i=0;
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', inputs.inc_sys_id);
gr.addQuery('table_name', 'incident');
gr.query();
while(gr.next()){
var file = gr.getValue('file_name').toString();
fileName.push(file);
}
for(var i=0;i<fileName.length;i++){
var GRattach = new GlideRecord('sys_attachment');
GRattach.addQuery('file_name',fileName[i]);
GRattach.query();
if(GRattach.next()){
var sa = new GlideSysAttachment();
var fileContent = sa.getContent(GRattach).toString();
attachments.push(fileContent);
}
}
outputs.file_name = fileName;
outputs.content = attachments;
I am getting the fileName and content as an array but something is not working when i try to send the payload.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2024 11:52 PM
Hi Priyadarshan,
How did you accomplish this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 01:25 AM
Hi @Raju86866 ,
I created a flow on the Attachment table. And I created an action to call the REST method. In the REST step, content type is set to Binary and pass the sys_id of the attachment record. So, when a record is created in the attachment table, the action will run and send the payload.
Hope this helps.