How to send multiple attachment using Rest message for current incident

String
Kilo Sage

Hi team ,

we wrote a BR to capture the attachment and convert o base 64,But i am facing issue to capture the multiple attachment for current incident 

 

var tarRec = new GlideRecord(current.table_name);
var sa = new GlideSysAttachment();
var binData = sa.getBytes(current);
var base64Data = GlideStringUtil.base64Encode(binData);
var Attachment = new sn_ws.RESTMessageV2('ABC', 'XYZ');

Attachment.setStringParameterNoEscape('att_data', base64Data);
Attachment.setStringParameterNoEscape('att_type', current.content_type);

1 ACCEPTED SOLUTION

@kiranchand 

did you use variable substitution for setting the attachment data?

you should create variable substitution something like this and then set the data

{ "ABC":"12345",
"Mode":"Attachments",
 
"Attachments": "${attachmentData}"
}
 
find_real_file.png
Refer link below:
 
 
Regards
Ankur
Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

check here and the proposal solution:

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

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

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is the 3rd party accepting multiple attachments in single request?

please check with them and accordingly you can include those in the json request body

Regards
Ankur

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

Yes in a single request have to send multiple attachment 

@kiranchand 

then please check what should be the format.

i.e. which json key values are to be repeated

Example: My assumption below

[{

"att_data": "base64Data",

"att_type": "application/pdf"

},

{

"att_data": "base64Data",

"att_type": "application/txt"

}

]

you will have to iterate over and form the json body accordingly.

Regards
Ankur

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