- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 04:48 AM
Dear experts,
Here is my BR in my second servicenow instance, i wanted to replace the hard coded values(highlighted) of the code, so that , it takes the newly created incident's parameters(like current.short_description, current.impact etc) and transfers that to instance 1
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody("{\"short_description\":\"created on 24-8-2018\",\"impact\":\"1\",\"urgency\":\"1\",\"description\":\"connected two servicenow instances and trying to pass data\"}");
var response = request.execute();
gs.log(response.getBody());
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 06:57 AM
BTW, I spent almost the entire session on today's community live stream on this same example. You can find it on YouTube on the Community Live stream 2018-08-27 show.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 04:51 AM
Hi,
Copy the code from preview script Usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 04:52 AM
Hi,
I think in previous thread i have given the answer. Please Do as below,
try {
var r = new sn_ws.RESTMessageV2('RestTest', 'Post');
r.setStringParameterNoEscape('short_description', current.short_description);
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthentication(authentication type, profile name);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.getMessage();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 05:49 AM
I have a question... i tried to use the "API explorer " in instance 1 to get the servicenow script and used it in instance 2's Business Rule created for the incident table. I have not created any REST message. whenever i create a new incident in instance 2, it creates a subsequent incident in instance 1, but the parameters are all hard coded. Do i need to create a rest message if i have to integrate the two instances?
Regards,
Sriram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2018 06:09 AM
Yes, You need to create RESTMessage because in the code provided by me RestTest is a Rest message name. If you create one REST message which you can use for all the CRUD operations. There you'll get clear idea about all operations and errors.