API Service Template
Introduction
The API Service Template equips implementers with a variety of inputs derived from the RestContext class itself, seamlessly integrating these into the flow. When your API service is connected to a flow utilizing the Plinqx API Service Template, all input and output variables are pre-configured for your convenience.
Creating a New Email Service Flow
To create a new API Service Flow in Salesforce.
-
In Setup go to 'Flows'.
-
Click the 'New Flow' button.
-
From the new flow screen, select the 'All + Templates' tab.
-
From here search and select the Plinqx API Service Template from the list.
Layout
The API Service Template comes ready-made to offer comprehensive coverage of all HTTP scenarios, including GET, POST, PUT, PATCH, and DELETE. You can utilize this as a foundation to seamlessly expand upon your desired logic.
Always keep in mind the guidance outlined in "Approaching a New Integration with Plinqx," "Considerations for Plinqx in Salesforce," and adhere to Plinqx Best Practices throughout your design process.
Please see the below table for avaibable input and output variables within the template
Variable | Type | Input / Output | Description |
---|---|---|---|
request | Apex-Defined | Input | The request of the API call made to your API Service |
response | Apex-Defined | Output | The response of your API service flow |
Variables Explained
Request
The request Apex-Defined variable is a wrapper that combines all the important inbout required for your logic in the flow. These inputs are gathered by Plinqx from the Rest Request that has been executed as part of the integration call to your defined service.
It has the following attributes:
Attribute | Type | Description |
---|---|---|
headerList | Collection ofPlinqxV2.RequestKeyValuePair | Both standard and custom HTTP request headers represented as a Key Value in a list.Custom headers can include agreed headers as defined in your implementation for examplex-page-size = 10
Use the Get Key Value component to extract specific keys within the list. |
httpMethod | String/Text | The HTTP method that was called:* GET |
-
POST
-
PUT
-
PATCH
-
DELETE | | remoteAddress | String/Text | The IP address of the client making the request. | | requestBody | String/Text | A JSON format of the request made - use the JSON Parser component to read the content of the body - you can also use the Convert to JSON Collection, and Transform JSON Object components to support your logic | | requestURI | String/Text | The URL string after https://<your instance>/services/apexrest/PlinqxV2/v1/services/... of your API service that was called with the request. | | resourcePath | String/Text | The REST resource path for the request. | | parameters | String/Text | A JSON string representing the paramaters passed. | | parameterList | List<String> / Collection of Text | Not in use. | | topicparameterList | Collection of PlinqxV2.RequestKeyValuePair | The parameters passed as topics in your request eg. if your API service was
account/{0}/{1}
** this list will be populated with the values passed as 'topics' in{0}/{1}
asRequestKeyValuePair.key - 0 RequestKeyValuePair.value - {0}
if the request sent wasaccount/us/12345
the list will be:RequestKeyValuePair.key - 0 RequestKeyValuePair.value - us RequestKeyValuePair.key - 1 RequestKeyValuePair.value - 12345
Use the Get Key Value component to extract specific keys within the list. | | topics | String/Text | A JSON string representing the topicparameterList. | | qryparameterList | Collection ofPlinqxV2.RequestKeyValuePair | The query parameters passed in your request eg. if your API service wasaccount
**and a request was made as account?accountNr=1234&country=us
this list will be populated asRequestKeyValuePair.key - accountNr RequestKeyValuePair.value - 1234``RequestKeyValuePair.key - country RequestKeyValuePair.value - us
Use the Get Key Value component to extract specific keys within the list. | | qryparameters | String/Text | A JSON string representing the qryparameterList. |
Response
The response Apex-Defined variable is a wrapper passes the output of your flow logic back to the client via Plinqx. This wrapper is processed within Plinqx and presented to the client as a REST Response.
It has the following attributes:
Attribute | Type | Description |
---|---|---|
headerList | Collection ofPlinqxV2.RequestKeyValuePair | Both standard and custom HTTP response headers represented as a Key Value in a list.Custom headers can include agreed headers as defined in your implementation for examplex-page-size = 10
|
statusCode | Integer / Number | The response code that needs to be passed back to your calling client - please refer to the standard industry response codes**Note: **It is required to pass back a response code of 200 or 201 if your flow has passed through successfully, equally as important to manage other response codes in your logic to return errors as required. |
status | String/Text | A short status message to be returned to the calling client, please refer the to the industry standard HTTP messages |
responseBody | String/Text | The JSON response (Text/String) to return to the calling client. This is the JSON that you have been constructing throughout your flow using a combination of:* Text templates as Plain Text with Merged Fields. |
-
Fomula Text Variables
-
Convert CSV to JSON | | messageId | String/Text | Not in use. |