- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:04 AM
Hi Community,
I need to understand what is HTTP Query Parameters in Outbound REST Message & Content? Also, I would like to know what is Variable Substitution in Outbound REST Message.
Can someone please explain these to me in a layman language?
Thanks,
Utpal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:38 AM
Hi @Utpal Dutta
Let's break down the concepts of HTTP query parameters and variable substitution with help of real world examples
1. HTTP Query Parameters:
When you make a request to a website or web service, you often include additional information or instructions. These instructions can be passed in the form of HTTP query parameters.
Imagine you're ordering a pizza online. You might specify the size, toppings, and delivery address. These details are like query parameters, providing additional instructions to the pizza place.
Similarly, in an Outbound REST Message, HTTP query parameters allow you to send specific data along with your request to the external service. It helps you communicate your requirements or provide additional context to the service you're calling.
2. Variable Substitution:
Variable substitution in an Outbound REST Message allows you to dynamically insert values into the request being sent to the external service. Think of it as a way to fill in the blanks with actual values.
Let's say you have a template letter where you need to mention the recipient's name and address. Instead of writing the same letter multiple times for different recipients, you can create a template with placeholders for the name and address. Then, you substitute those placeholders with actual names and addresses when you send the letter.
In an Outbound REST Message, variable substitution works similarly. You define placeholders or variables in the request, and at runtime, you substitute those variables with actual values from ServiceNow records, user inputs, or other sources.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 05:38 AM
Hi @Utpal Dutta
Let's break down the concepts of HTTP query parameters and variable substitution with help of real world examples
1. HTTP Query Parameters:
When you make a request to a website or web service, you often include additional information or instructions. These instructions can be passed in the form of HTTP query parameters.
Imagine you're ordering a pizza online. You might specify the size, toppings, and delivery address. These details are like query parameters, providing additional instructions to the pizza place.
Similarly, in an Outbound REST Message, HTTP query parameters allow you to send specific data along with your request to the external service. It helps you communicate your requirements or provide additional context to the service you're calling.
2. Variable Substitution:
Variable substitution in an Outbound REST Message allows you to dynamically insert values into the request being sent to the external service. Think of it as a way to fill in the blanks with actual values.
Let's say you have a template letter where you need to mention the recipient's name and address. Instead of writing the same letter multiple times for different recipients, you can create a template with placeholders for the name and address. Then, you substitute those placeholders with actual names and addresses when you send the letter.
In an Outbound REST Message, variable substitution works similarly. You define placeholders or variables in the request, and at runtime, you substitute those variables with actual values from ServiceNow records, user inputs, or other sources.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 06:49 AM
Thank you @Manmohan K for explaining this to me with such a good example. I also want to know can we substitute Query Parameters with help of content by writing ${DYNAMIC VALUE}. If I do this, will it add variable under Variable Substitution related list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2023 07:47 AM - edited 07-17-2023 07:48 AM
Hi @Utpal Dutta
1. To add query parameter use below method -
setQueryParameter(String name, String value)
var sm = new sn_ws.RESTMessageV2();
//Set up message, including endpoint and authentication
sm.setQueryParameter("sysparm_query","active=true^ORDERBYnumber^ORDERBYDESCcategory");
2. For Variable Substitution, use below method
setStringParameterNoEscape(String name, String value)
sample code -
var sm = new sn_ws.RESTMessageV2("<REST_message_record>","get"); //Might throw exception if message doesn't exist or not visible due to scope.
sm.setStringParameterNoEscape("s","NOW");
.