Get attachments through rest message

p t1
Kilo Sage

Hi Team,

 

I want to get attachments from one instance to another instance through rest message.

 

For example: Incidents created on this week and if all tickets having an attachment then all attachments should be get in another instance through get method.

 

Can anyone help on this?

 

Thanks

9 REPLIES 9

Niklas Peterson
Mega Sage

Hi @Niklas Peterson 

 

Scenario : I have one catalog item and there few attachments in those in RITM, I want to fetch only those through rest api.

 

Thanks,

Preethi

Hi,

You need to spend some time on the design on this. There are decisions that needs to be made. Like should you push the data from one instance to the other or do you want to pull. Do you want to run it scheduled or should you have the attachments sync as soon as they are added etc.

Have a look at the solution of this old community post for some inspiration.
https://www.servicenow.com/community/developer-forum/copying-attachment-from-one-instance-to-another...

 

Regards,

Niklas

Hi Niklas. The documentation link is broken.

I think you should use this format:

 r.setSaveResponseBodyAsAttachment(
            'table',              
            current.sys_id,              
            'my_file.pdf'
);

 

Where r is an instance of RESTMessageV2 but I don´t broken me.