REST API Mapping
The REST API Mapping implementation type lets you map methods to REST API endpoints without writing code. This is useful when the method can be implemented with a single REST API call.
Use the following file naming structure for the REST API mapping implementation:
<method-name>.rest.yml
Example
# list.rest.yml
path: /contacts
method: GET
requestMapping:
query:
limit: 100
offset: { $var: $.cursor }
email: { $var: $.filter.email }
first_name: { $var: $.filter.firstName }
include_archived: { $var: $.parameters.includeArchived }
responseMapping:
records: { $var: response.data.contacts }
cursor: |
{
$cond: [
{ $var: response.data.hasMore },
{ $string: { $sum: [{ $number: { $var: $.cursor } }, 100] } },
null
]
}
Format
The mapping specification includes:
path
– The API endpoint pathmethod
– HTTP method (GET, POST, PUT, PATCH, DELETE)requestMapping
– Request mappingquery
– Query parameters mappingheaders
– Headers mappingdata
– Request body mapping for POST/PUT/PATCHpathParameters
– Values for placeholders in the path (e.g.,{projectId}
)
responseMapping
– Mapping to transform the API response
Variables
Besides function-specific input variables described in each function's documentation, functions have the following variables available:
- All functions inside the connector have
credentials
variable that contains credentials from the current connection.- The only functions that don't have it are auth functions used before the connection is created. They have
connectorParameters
andconnectionParameters
variables instead.
- The only functions that don't have it are auth functions used before the connection is created. They have
- All data collection function have
parameters
variable that contains function-level parameters and collection-level paramteres combined.
For responseMapping
, you get an additional response
variable that has the following fields:
data
– API response dataheaders
– API response headersstatusCode
– API response status code
Updated 9 days ago