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

Ankur Bawiskar
Tera Patron
Tera Patron

@rajasekharteja 

So 3rd party will send the attachment data?

you can use Scripted REST API and inform 3rd party to send data as per this format and ensure they send all the data at once when they hit the API

refer this link and enhance your logic

Scripted Rest API to update incident with attachment 

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

Hi @Ankur Bawiskar ,

 

Thanks for providing quick response on this.

 

In my Instance file format we are using is Pdf, as you stated in other chain mentioned below do we need to use Attachment creator only?

https://www.servicenow.com/community/itsm-forum/scripted-rest-api-to-update-incident-with-attachment...

for other file you can use SOAP Attachment creator and you require the following details

file name, content type, base64encoded data, record sysId, table name

 

Thanks,

Raj

@rajasekharteja 

you can use Attachment Creator or GlideSysAttachment API as well

what did you start with and where are you stuck?

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

rajasekharteja
Tera Guru

@Ankur Bawiskar 

I used attachment creator as below 

 

{

"agent" : "attachmentCreator",

"topic":"attachmentCreator",

"name":"Test.pdf",

"source":"incident:sys_id",

"Payload":"Base64 encodedstr"

}

 

I used the above format and the attachment is getting attached to the record.

 

Now My question is can multiple attachments can be send in a single api request.

 

Thanks,

Raj