
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2019 11:30 AM
I'm learning how to eBond from one SN instance to another using REST and Web Services tables, and am having some success, but I'm very frustrated trying to piece together the information I need to send attachments from an incident on the source to the corresponding incident on the target.
I have followed this post step by step, as it was the most straightforward solution I could find
https://servicenow-docs.readthedocs.io/en/latest/Sending_Attachments_via_REST/index.html
but it had some gaps that I've had to work through. I am to a point where attachments are getting sent from the source incident when expected, but they are sitting in a 'ready' state in the ecc_queue on the target instance. What else do I need to do to get them attached to the target incident?
There are probably better ways to do what I'm trying to do, but finding start-to-finish, step-by-step documentation has been fruitless and I have spent far too much time on this already.
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2019 01:20 PM
You can use below service now code to consume attachment aPI to POST attachments from one service now instance to another.
You need to create business rule on sys_attachment table to consume REST API from another instance to post attachment like below
(function executeRule(current, previous /*null when async*/) {
var grInc = new GlideRecord('incident');
if(grInc.get(current.table_sys_id)){
if(grInc.correlation_id != ''){ //if abc SN sys_id exists on the incident
try {
var r = new sn_ws.RESTMessageV2('xxx', 'POST');
r.setRequestHeader("Accept", "Application/json");
r.setRequestHeader("Content-Type", current.content_type);
r.setQueryParameter("table_sys_id", grInc.correlation_id);
r.setQueryParameter("file_name", current.file_name);
r.setQueryParameter("table_name", "sn_customerservice_case");
r.setRequestBodyFromAttachment(current.getUniqueValue()); //assign attachment to body
gs.log('[EBOND ATTACHMENT LOGS] - Attempting to POST the following attachment to the XYZ SN instance:\n'+current.file_name+', '+current.getUniqueValue()+', '+current.content_type);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parser = new JSONParser();
var parsed = parser.parse(responseBody);
gs.log('[EBOND ATTACHMENT LOGS] - Attachment '+current.number+' pushed to XYZ SN instance into Case '+parsed.result.sys_target_sys_id.value+'.\nHTTP Status '+httpStatus);
gs.log('[EBOND ATTACHMENT LOGS] - Response:\n' + responseBody);
}
catch (ex) {
gs.log('[EBOND ATTACHMENT LOGS] Error in Attachment POST to XYZSN instance.\n' + ex.message);
}
}
}
})(current, previous);
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2019 07:32 AM
As a side note, the rest_service user I was using to connect only had the rest_service role. I had to add read access to the incident table to the rest_service role in order for this to work when adding attachments to existing incidents. Before I did that, I was getting 404 not found.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2019 06:17 PM
Hi Kchorny, Sachin,
I have similar requirement,
can you please help.It is a quite urgent.
1. I want the team to build a SOAP connectivity between two SN instances to send JSON message 2. Send an encrypted attachment from source and decrypt the attachment in the target system. The encryption could be a an encryption key in combination of User ID and Password.
Thanks!!
Krishna