Summary
This article explains how to configure REST Step in Integration Hub.
In this example outbound REST call is made from one ServiceNow instance to another ServiceNow instance.
Release
- Install Integration Hub Plugin
- Connection & Credential Aliases -> New -> Type is 'Credential'
- Open the created 'Connection & Credential Aliases ' from step above -> Credentials -> New -> Basic Auth Credentials (or any other credentials type that your end point is configured with)
- Flow Designer -> Designer -> Actions -> New -> Action -> Give a Name and save
- Click on '+' sign under Inputs ->Select Step to Add -> Integrations -> REST
- Connection -> Define Inline Connection
- Connection Alias -> select the one cerated from step 2
- Base URL -> https://<instance_name>.service-now.com
- Resource Path -> /api/now/table/incident
- HTTP Method -> POST
- Headers -> Accept : application/json
- Request Content -> Request Type -> Text -> {"short_description":"From REST step","description":"From REST step"}
- If you want to add a "Script step" to parse the response below are the steps
- Click on "+" -> Script
- Input variables -> Create Variable
- Configure as per the attached screenshot
- Script
-
(function execute(inputs, outputs) {
var responseBody = JSON.parse(inputs.response);
if(inputs.status!=201){
var errorMsg = responseBody.error.message;
var errorDetail = responseBody.error.detail;
throw "Error retrieving incident. Message: "+errorMsg + " Details:"+errorDetail;
}
else {
var result_field = responseBody;
outputs.short_description = result_field.result.short_description;
outputs.number = result_field.result.number;
}
// ... code ...
})(inputs, outputs); - The above script with parse the response and store the response values ( in this case short_description and number ) in output variables.
- If you want to store parsed response in Output Variables you can create 'Output Variables' as shown below
- "Save" the action and "Test" to check if you get successful response.