- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 05:30 AM
Hello community,
I try to call an external API with a defined JSON in case an incident is created.
I saw this video:
#4 Rest Outbound Integration in ServiceNow| Rest Message |Create an Incident in third party tool (https://www.youtube.com/watch?v=YE7jcl-5whs)
this is my code: in the business rule:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var request = new sn_ws.RESTMessageV2('RESTTEST','RESTTESTPOST');
//request.setStringParameterNoEscape('u_caller',current.caller_id);
//request.setStringParameterNoEscape('u_short_description',current.short_description);
request.setStringParameterNoEscape('u_sd',current.short_description);
var response = request.execute();
var responseBody = response.getBody();
var statuscode = response.getStatusCode();
var errorMsg = response.getErrorMessage();
gs.info("responseBody"+responseBody);
})(current, previous);
The trigger works fine, the external API is called, but i just see
in the text field I want to transmit not the data stored in "current.short_description" in my variable to be replaced (u_sd)
REST Message:
"text" : "$(u_sd)".
So i would need the value stored in "current.short_description" be transmitted in the REST call and NOT like at the moment the pure placeholder "$(u_sd)". Do I have to build the whole final string to be sent in the business rule code?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 03:35 AM
Did you create a variable substitution for your placeholder?
If not then it won't work
Variable substitution in outbound REST messages
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 05:25 AM
@Ankur Bawiskar : Used the wrong brackets...of course it works correctly. Sorry for bothering you with that issue.