Configure and Send Outbound REST API Requests in Qntrl | Web Services in Qntrl | Qntrl Onlline Help

Create and configure an Outbound REST API

Outbound REST Web Services enables users to interact with external web services by sending HTTP requests to retrieve, create, update, or delete data on REST-compliant servers. This functionality is designed to integrate seamlessly with external APIs and is flexible enough to support a wide variety of use cases.


Key Capabilities

  • Send REST API requests using GET, POST, PUT, or DELETE methods.

  • Include parameters, headers, and body content in your requests.

  • Use variables to pass values dynamically at runtime.

  • Parse API responses to extract specific data for further use in workflows.

You can trigger outbound REST calls from any scripting-supported area in Qntrl, such as Business Rules, Circuits, and Standalone Functions.

Let's see the step-by-step procedure to configure and send an outbound REST request from Qntrl to an external system.

Create an API 

To create a REST API configuration in Qntrl:

  1. Navigate to (settings) >> WEB SERVICES >> Outbound >> Click REST.

  2. Click Create API in the top-right corner.

  3. Enter a name for the API in the left sidebar.

  4. Select the HTTP method: GET, POST, PUT, or DELETE.

  5. Enter the API URL (endpoint) of the service to which the request should be sent.

  6. Enable Connection (Checkbox): Select this checkbox to send the request through a DRE connection.
    • Once selected, a dropdown appears with available connections.
    • Choose an existing connection or create a new one.
    • The connection status is shown with a color indicator:
      1. Green means the connection is active.
      2. Red means it’s inactive.

      

  

Request Configuration 

You can pass input to the API using Query Parameters, Headers, and Body formats. Click the Request Configuration section and provide the necessary details for each.
Notes
For all sections—Query Parameters, Headers, and Body—you can use static or dynamic values in the following formats:
  • {{variableName}} for runtime values.
  • ${configstore-name} to use values from the Config Store.
  • Directly entered literal values.
Use the + icon to add fields or to remove them as needed.
  1. Query Parameters  : Define key-value pairs to be appended to the API URL.
    • KEY: Name of the query parameter.

    • VALUE: Input based on the formats mentioned above.

      

  1. Headers  : Set required HTTP headers for the request.

    • KEY: Header name (e.g., Authorization)

    • VALUE: Input based on the formats mentioned above.

      

  1. Body (POST & PUT Only)  : Select the format and provide the data.

    • None: Select this if the request does not require a body.

    • form-data: Enter the keys and values.

    • x-www-form-urlencoded: Enter the keys and values.

    • Raw: Supports Text, JSON, or XML for complex payloads.

      

  1. Test API with variable values: Use the refresh icon to load the available variables. Enter sample values for each variable to test the API request. This helps you verify the configuration before saving. After sending the request, you can view the test response in the Response tab.

      

Notes
  • The test feature is for validation purposes only and does not affect the actual saved configuration.                        
  • You can add up to 20 key-value pairs in the request configuration.
  • A maximum of 20 JSON paths can be defined in the Response Parser.

Using Variables in REST Requests  

You can insert variables anywhere in the request configuration using the {{variableName}} syntax.

  • Static Values: Entered manually in the UI (via "Test API With Variable Values").

  • Dynamic Values: Passed at runtime using scripts or Codex.

When triggering from Codex, provide variables as a JSON object:

{
  "jobId": "1123",
  "email": "john.doe@swerio.com"
}

These values will replace the placeholders {{jobId}} and {{email}} across Query Params, Headers, and Body.


Response Parser  

After execution, use the Response Parser to extract specific data from the JSON response.

  • Qntrl automatically filters the response and suggests commonly used JSON paths.

  • From the suggestions, click ADD next to a path, give it a name, and click SAVE to store it.

  • You can add multiple fields to extract the data you need.

      

The extracted values will appear as the Applied Response during the next execution, displayed alongside the full original response.


Scripts to Modify the Outbound REST Request or Response 

Pre Script  

Use the Pre Script to run custom logic before the API request is sent. Pre Scripts are executed automatically just before an outbound REST API call is made.This feature is especially useful when you need to dynamically alter query parameters, headers, body or variable values based on business logic or runtime conditions.

Sample CodeX
function beforeSend() {
    try {
        
        var queryParams = webservice.outboundREST.getQueryParameter();
        console.log("Query parameters "+queryParams);
        // Add a new query parameter.
        var timestamp = new Date().toISOString();
        webservice.outboundREST.addQueryParameter("timestamp", timestamp);
        // Replace variable values.
        var variables = {};
        variables["user_id"] = "21499000000115251";
        webservice.outboundREST.replaceVariableValues(variables);
        // Add a custom header
        webservice.outboundREST.addHeader("x-tracking-id", "track-" + Date.now() );
        console.log("Modified query params --> " + webservice.outboundREST.getQueryParameter());
        console.log("Modified headers --> " + webservice.outboundREST.getHeader());
    } catch (e) {
        console.log("Error in beforeSend: " + e.message);
        webservice.outboundREST.setResponseCode(500);
    }
}

How It Works  
  • The beforeSend() function is invoked automatically before the request is dispatched.
  • You can access and modify requests by adding dynamic parameters, headers, and values required for successful integration with external systems.
  • It allows developers to adjust the outgoing request programmatically, ensuring that it contains the correct parameters, authentication values, and tracking information.

Post Script  

Post Scripts allow you to run custom logic after an outbound REST API response is received. They are useful for adjusting the final output before it's passed to the rest of your process.
  • You can modify the response code, headers, or data.
  • The defined response parser will automatically run on the response, and its output will be available as the applied response.
  • The modified response from the Post Script will be got as the final response.
Sample CodeX
function afterSend()
{  
    var appliedResponse = JSON.parse(webservice.outboundREST.getAppliedResponse());
    console.log("appliedResponse -->" + appliedResponse);
    var variables = JSON.parse(webservice.outboundREST.getVariableValues());
    var varJson = {};
    varJson['account_id'] = appliedResponse.CRM_Account_ID;
    varJson['oauth_token'] = variables.oauth_token;
    var crmResponse = OutboundREST.executeByName("GetAccountDetailsCRM", varJson);
   if (!crmResponse || Object.keys(crmResponse).length === 0)
   {
     webservice.outboundREST.setResponseCode(500);
     webservice.outboundREST.addResponseHeader("crm_error","unable to fetch CRM data.");
   }
  else
  {
    appliedResponse['crmResponse'] = crmResponse;
    webservice.outboundREST.setAppliedResponse(JSON.stringify(appliedResponse));
    console.log("appliedResponse -->" + JSON.stringify(appliedResponse));
  }  
}

How It Works  
  • The afterSend() function is triggered automatically after an outbound REST API request is made.

  • It retrieves additional details from an external CRM system using data received in the initial API response.

  • The final response contains both the original data and enriched CRM data.

This is especially useful when you need to clean, transform, or extract specific values from the raw API response before using it further.


Configure Additional Settings 

Click the Settings tab and enter the following details:
  1. Connection Timeout: The maximum time allowed to establish a connection between the client and the server (default: 5 seconds).
  2. Scope: Define the scope or permission level.
  3. SSL Certificate Verification: Enable this option if your server requires SSL certificate validation. 
    1. Qntrl will verify the server’s SSL certificate when sending requests to ensure secure communication.
    2. The certificate is fetched based on the host and port in the URL.
    3. If multiple certificates are available for the same host and port, the most recently added one will be used.
    4. If the port is not specified in the URL, Qntrl will default to port 443 (standard for HTTPS).
      

Save and Execute the Request     

To save the configuration:

  • Click Save. The API will now be listed in the left sidebar.

  • Click Send to execute and test the API. This also saves the API configuration.

  • After execution, view results under the Response tab.

Notes
Editing test results does not change the actual configuration. Always save updates before re-testing.

Execute Outbound REST in Codex  

You can execute the outbound REST function using Codex with the following methods:
Execute by ID  

Use the unique ID of the configured REST API to trigger execution via script.

Syntax

OutboundREST.execute("<api_id>", <variables>);
Sample Request
let requestData = {};
requestData["approvalStatus"] = "Approved";
OutboundREST.execute(31453000002078039, requestData);


Execute by Name  

Call the REST API using the configured API name and a key-value pair object of variables.

Syntax

OutboundREST.executeByName("api_name", <variables>);
Sample Request
let requestData = {};
requestData["approvalStatus"] = "Approved";
OutboundREST.executeByName("TaskApprovalAPI", requestData);
These executions dynamically replace placeholders (e.g.,{{approvalStatus}}) in the REST API configuration using the values provided through the requestData object.

Other Actions 

You can manage your Outbound REST API using the available options in the left panel.

  • Enable or Disable: Use the toggle switch next to the API name to activate or deactivate the API.

  • Rename or Delete: Click the more actions (...) icon next to the API and choose Rename or Delete as needed.

      





Next:


  












    • Related Articles

    • REST API

      Access Privilege API key can be generated only by the Organization Owner. An API key provides a one-time authentication for triggering API calls in Qntrl. Only the standalone custom functions can be invoked using the API key. Navigate to and select ...
    • Configure Inbound REST API

      Qntrl’s Inbound REST Web Service allows you to create custom API endpoints that external users or systems can call to perform specific actions inside Qntrl. When a user triggers the API, Qntrl receives the request and processes it based on the ...
    • Create and Configure Outbound SOAP Message

      Outbound SOAP services in Qntrl enable communication with external SOAP-based APIs. These services rely on WSDL (Web Services Description Language) contracts that define available operations and parameters. Let's see how to create and configure an ...
    • Custom Function: Create_Job

      This custom function can be used to create a new card in any board. It can also be configured to carry forward necessary field values from the former card to the latter. Business Scenario Helen is the head of Procurement Management in her ...
    • Manage Custom Functions

      Custom functions allow users to develop and execute user-defined functions using Deluge. You can execute simple program snippets to automate processes, or integrate with third-party or Zoho applications. Business Uses for Custom Functions Use Custom ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.