How do I get correlation id through REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2022 11:43 PM
I want to make it as bi-directional communication of both servicenow instance, but correlation id is not populating..
Thanks in advance
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 09:20 AM
This is my Br:
(function executeRule(current, previous /*null when async*/ ) {
var r = new sn_ws.RESTMessageV2('example-rest', 'REST');
r.setStringParameterNoEscape("u_number", current.number);
r.setStringParameterNoEscape("u_caller_id", current.caller_id);
r.setStringParameterNoEscape("u_state", current.state);
r.setStringParameterNoEscape("u_category", current.category);
r.setStringParameterNoEscape("u_short_description", current.short_description);
r.setStringParameterNoEscape("u_impact", current.impact);
r.setStringParameterNoEscape("u_urgency", current.urgency);
r.setStringParameterNoEscape("u_priority", current.priority);
r.setStringParameterNoEscape("u_subcategory", current.subcategory);
r.setStringParameterNoEscape("u_assignment_group", current.assignment_group);
r.setStringParameterNoEscape("u_description", current.description);
var response = r.execute();
var responseBody = response.getBody();
var json = responseBody;
var obj = JSON.parse(json);
var foundsysID = obj.result.sys_id;
current.correlation_id = foundsysID;
current.update();
})(current, previous);
and same fields are mentioned in REST message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 09:24 AM
Hi,
are you sure you are getting the sys_id in response?
are you parsing it correctly?
I assume your BR should be after insert.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 09:28 AM
I think BR is not correct that's why REST API showing 500 internal server error..
could you help me with scripting part along with correlation id.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 08:20 PM
Hi,
seems the function is incorrect i.e. REST
it should be POST
Also check you have defined the JSON request in content body or not
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 04:48 AM
Hi All,
Seems I have an similar issue.
We r creating e-bonding b/w X & Y company.
X company creates incident & same data flows & created Incident in Y company.
When same incident is created in Y company.
We want to receive the incident number of Y company & store on correlation_id of X company.
Also add 'Y' in response. So we can understand this is coming from Y company.
Ex:- 'Y 1234' (Incident of Y company)(Stored at X company correlation field).