- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2024 03:58 AM
Hi,
How to send attachment from one instance to another instance. When I'm creating incident in one instance it is creating in another instance with having same details and I want to send attachment from one instance to another instance.
Can anyone please tell how to send attachment from one instance to another instance.
Regards,
Nivedita
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2024 12:22 AM - edited ‎03-08-2024 12:40 AM
Hi @niveditakumari Sure you can DM me. You can also take a look at documentation below
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2024 10:48 AM
Hi @niveditakumari ,
Check the below links,
There are solutions already available.
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2024 11:12 AM
Hi @Sumanth16,
I have already gone through that link that is with soap and I need to achieve it with REST API.
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2024 07:37 PM
Hi @niveditakumari is it from servicenow to servicenow? if yes you can use OOB Attachment API like below,
create rest api and BR on incident table like this
var user = 'aaa';
var password = 'xxx@';
var attachmentRec = new GlideRecord("sys_attachment");
attachmentRec.addQuery('table_name','incident');
attachmentRec.addQuery('table_sys_id',current.table_sys_id);
attachmentRec.query();
gs.log("--> "+attachmentRec.getRowCount());
if (attachmentRec.hasNext()) {
while (attachmentRec.next()) {
var attachmentMessage = new sn_ws.RESTMessageV2();
attachmentMessage.setHttpMethod("post");
attachmentMessage.setBasicAuth(user,password);
attachmentMessage.setEndpoint("https://devxxx.service-now.com/api/now/attachment/file");// other instance end point
attachmentMessage.setQueryParameter("table_name", "incident");
attachmentMessage.setQueryParameter("table_sys_id", attachmentRec.u_test);
attachmentMessage.setQueryParameter("file_name", attachmentRec.file_name);
attachmentMessage.setRequestHeader("Content-Type", attachmentRec.content_type);
attachmentMessage.setRequestHeader("Accept", "application/json");
attachmentMessage.setRequestBodyFromAttachment(attachmentRec.sys_id); // send the attachment as request Body
var response = attachmentMessage.execute();
var responseBody = response.getBody();
gs.log("* responseBody "+ responseBody);
var httpStatus = response.getStatusCode();
gs.log("* atatch "+ httpStatus);
}
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2024 12:14 AM
Hi @Harish KM,
Thank you for your help.
I have gone through above code and tried to understand but not understood completely. Can we connect?
Can you please help me to make me understand.
Regards,
Nivedita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2024 12:22 AM - edited ‎03-08-2024 12:40 AM
Hi @niveditakumari Sure you can DM me. You can also take a look at documentation below
Harish