How To: Create a Variable Endpoint for an Integration Gateway Recipe
Overview
The Integration Gateway supports variable path parameters for endpoints. Variable path parameters let you insert a dynamic value into an pathway. For example, if you create an Unqork Connector that retrieves a module's submission data, you can create an endpoint with a variable parameter that uses the module's ID in the pathway.
Variable path parameters let you create endpoints similar to Unqork's API. For example, the Unqork Get Module Submissions API endpoint looks like the following: https://{host}/api/1.0/modules/{moduleId}/submissions. The {host} and {moduleId} values are variables that you replace to target a specific environment and module.
Create a Variable Endpoint for an Existing Recipe
For this example, you'll create and connect a variable endpoint to an existing recipe. Later, we'll set up a module with a Plug-In component that targets the variable endpoint.
What You Need
Creating the Variable Endpoint
First, use the Integration Gateway to create a new endpoint for an existing recipe. These instructions assume you have an existing recipe where you'll create an endpoint.
For this example, we'll use the Integration Gateway recipe set up in the How to: Retrieve a Payload Using an Unqork Connector article.
To create a new variable endpoint:
|
1.
|
At the top right of the Unqork Designer Platform, click . |
|
2.
|
Select Administration. |
|
3.
|
Under Integration, click API Access Management. |
|
4.
|
Select the API Platform tab. |
|
5.
|
Select your API Collection. |
|
7.
|
From the Recipe* drop-down, select an existing recipe. |
|
8.
|
From the HTTP Method* drop-down, select the request method for the recipe. For the Get Module Submissions endpoint, select GET. |
|
9.
|
In the Endpoint Name* field, enter a unique name. This value displays in a Plug-In component as an External Service. |
Configuring the Variable Endpoint Path
The Endpoint Path field accepts variable parameters. To create a variable parameter, use a single set of curly braces {} to enclose a variable value. For this example, the Unqork Get Module Submissions recipe uses the variable value moduleId to retrieve submissions from the specified module. Adding {moduleId} to the endpoint path displays the recipe's moduleId value when calling the endpoint.
|
1.
|
In the Endpoint Path*, enter a value that includes a variable parameter. For example enablement/{moduleId}/getModuleSubmissions. |
|
3.
|
On the endpoint tile, click the ··· (options) button. |
|
4.
|
Select Activate Endpoint. The endpoint's status changes from Never Active to Active. |
Your variable endpoint is now active for you to select it in a Plug-In component.
Configuration
The last step of the process is to configure a module to retrieve Unqork application data using the variable endpoint. These instructions assume you have a module saved with a title.
For this example, we'll use the Integration Gateway recipe set up in the How to: Retrieve a Payload Using an Unqork Connector article.
Configure the Text Field Component
Configure a Text Field component for entering the module ID. This value inputs into the Plug-In component you'll configure in the next step.
|
1.
|
In the Module Builder, drag and drop a Text Field component onto the canvas. |
|
2.
|
In the field, enter textModuleId. |
|
3.
|
In the field, enter Module ID:. |
Configure the Plug-In Component
Add a Plug-In component to use your new Integration Gateway endpoint and retrieve your workspace application.
|
1.
|
Drag and drop a Plug-In component onto your canvas, placing it below the textModuleId Text Field component. |
|
2.
|
In the and fields, enter plugGetModuleSubmissions. |
|
3.
|
Set the Service Type to External. |
|
4.
|
From the External Services drop-down, select the endpoint you created. |
|
5.
|
In the Data Source URL field, modify the variable value to use the module's textModuleId Text Field component value. For example, {{moduleId}} becomes {{data.textModuleId}}. Now, when users enter a value in the textModuleId Text Field component field, the Data Source URL updates the value between the brackets. |
|
6.
|
In the INPUTS table, enter the following: |
Configure the Button Component
Next, add a Button component to trigger the Plug-In component.
|
1.
|
Drag and drop a Button component onto the canvas, placing it below your Plug-In component. |
|
2.
|
In the field, enter btnGetModuleSubmissions. |
|
3.
|
In the field, enter Get Module Submissions. |
|
4.
|
Set the Action Type to Event. |
|
5.
|
In the Trigger field, enter plugGetModuleSubmissions. |
View the API Request Payload in the DevTools Console
Now that you've built your endpoint and created a module that can call it, verify the endpoint works correctly.
|
1.
|
Preview your module in . |
|
2.
|
Right-click anywhere in Express View and click Inspect. The displays. |
Your browser type and settings might look different than the image and steps displayed below.
|
3.
|
From the , select the Network tab. |
|
4.
|
In the Module ID field, enter a module ID that contains submission data. |
|
5.
|
Click the Get Module Submissions button. The execute request displays in the Network tab's list. |
|
6.
|
Select the execute request, then click Payload. The Request Payload data displays. |
In the Request Payload, the endpoint URL replaces the Plug-In component {{data.textModuleId}} variable parameter with the value from the textModuleId Text Field component field.
The endpoint URL updates every time you call the endpoint using a different module ID.
Resources