REST POST .setStringParameterNoEscape, $(...) - not replaced

lukaspfeiffer
Tera Contributor

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? 

Rest Outbound Integration in ServiceNow| Rest Message |Create an Incident in third party tool Please Like, Share & Subscribe my channel if you find my video useful and do let me know your doubts or queries in comment section below. Instagram : servicenow_adda Gmail : techie.adda123@gmail.com Blog
1 ACCEPTED SOLUTION

@lukaspfeiffer 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

lukaspfeiffer
Tera Contributor

@Ankur Bawiskar :  Used the wrong brackets...of course it works correctly. Sorry for bothering you with that issue.