Rest API : Getting multiple attachments from 3rd party and attaching it to the record at a time

rajasekharteja
Tera Guru

Hello All,

 

I got a requirement where I need to attach multiple attachments to the job record at a time.

 

I have used '"AttachmentCreator" but it's not allowing me to attach multiple attachments at a time to record.

 

Could anyone please help me with your inputs to accomplish this functionality.

 

Thanks,

Raj

1 ACCEPTED SOLUTION

@rajasekharteja 

you need to enhance the script I shared so that it iterates the array of json objects and then for each object use attachment creator

I hope that helps you

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

7 REPLIES 7

@rajasekharteja 

use array of json objects

[
{
"agent": "attachmentCreator",
"topic": "attachmentCreator",
"name": "Test.pdf",
"source": "incident:sys_id1",
"Payload": "Base64 encodedstr1"
},
{
"agent": "attachmentCreator",
"topic": "attachmentCreator",
"name": "Test2.pdf",
"source": "incident:sys_id2",
"Payload": "Base64 encodedstr2"
}
]

Then parse the array of json object and then for each object use the code I shared

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

rajasekharteja
Tera Guru

@Ankur Bawiskar 

I understood that we have to pass attachments as an array . 

 

Apologies, as I'm new to Integration I'm not getting whether we need to updated the code you provided or will it works for multiple attachments.

 

By seeing the code I assume it'll work for a single attachment, correct me if I'm wrong.

 

Also in Postman  what should be the end point to be passed to test if we construct similar to this.

 

Thanks, 

@rajasekharteja 

you need to enhance the script I shared so that it iterates the array of json objects and then for each object use attachment creator

I hope that helps you

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