Notifications

22 views

Description

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 or Environment

  1. Install Integration Hub Plugin
  2. Connection & Credential Aliases -> New -> Type is 'Credential'
  3.  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)
  4. Flow Designer -> Designer -> Actions -> New -> Action -> Give a Name and save
  5. Click on '+' sign under Inputs ->Select Step to Add -> Integrations -> REST
  6.   Connection -> Define Inline Connection
  7. Connection Alias -> select the one cerated from step 2
  8. Base URL -> https://<instance_name>.service-now.com
  9. Resource Path -> /api/now/table/incident
  10. HTTP Method -> POST
  11. Headers -> Accept : application/json
  12.  Request Content -> Request Type -> Text ->  {"short_description":"From REST step","description":"From REST step"}
  13. If you want to add a "Script step" to parse the response below are the steps
  14. Click on "+" -> Script
  15. Input variables -> Create Variable
  16.  Configure as per the attached screenshot
  17. Script
  18. (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);
  19.  The above script with parse the response and store the response values ( in this case short_description and number ) in output variables.
  20. If you want to store parsed response in Output Variables you can create 'Output Variables' as shown below
  21. "Save" the action and "Test" to check if you get successful response.

Article Information

Last Updated:2020-05-02 04:53:35
Published:2020-05-02