Within the definition setup of a REST service, you can use REST specific variables. These variables can be used in the REST definition such as urls, parameters, or headers. To take them one step further, a REST variable value can be assigned to a Global Variable.
- Navigate to Variables on the Rest Service Maintenance page.
- Placeholder – Enter the name of the variable. This is how the variable will be referenced later.
- Description – Enter a description for the variable.
- Type – Select System or Runtime.
- Value – Enter a value for the variable. This can be left blank. Additionally, this can be set to a global variable which allows an integration to pass a global variable to the rest variable.
- Required – Require a value to be entered for the variable on the connection setup.
Example uses for REST Variables
To reference a rest variable, enclose the Placeholder in double square brackets.
- URLs – storename and apiversion are the placeholders defined in the variables section.
- Parameters – searchquery is the placeholder defined in the variables section.
- Headers – ctype is the placeholder defined in the variables section.
- Setting value to a Global Variable – A global variable called GBL_CUSTOMERID can be set within an integration and its value can be passed into the rest definition variable.
Mappable REST Variables
Many times a rest service requires the endpoint to change for each request. An example would be doing an update to a record. The endpoint needs to have an id in it that changes for each record. We can set a rest variable in the endpoint and then make the variable mappable. This means when the integration is ran, the endpoint will change for each record being processed.
In the example here, [[customerid]] will dynamically change with mapped data from the source for each record. To set a variable to mappable, navigate to a rest service destination and click on Variables. Enable the mappable checkbox next to the variable. Now when mapping to this destination, there will be an extra destination field with a Target Name that matches the variable’s Placeholder name.