API Parameter Options
The options for passing parameters to a remote API from outbound stages and the Synchronous API-to-API stage.
There are a number of API-based outbound stages in Integration Hub, which result in a call to a remote API:
- Outbound Form Data Stage
- Outbound Proxy API Stage
- Outbound Proxy API Store Response Stage
- Outbound Proxy API Store Response Binary Stage
- Synchronous API-to-API Stage
All of these stages support the same options for passing parameters when the remote API is called.
GET APIs
When calling a remote API using the GET HTTP method, an HTTP body cannot be supplied to the endpoint being called, as the GET HTTP method does not support this.
However, it is possible to pass parameters to the remote API being called as part of the URL string.
GET APIs - No Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "GET",
"httpParametersMode": "none"
}
When the httpMethod is set to GET and the httpParametersMode is set to none, no parameters will be used when calling the remote API - the API will simply be called exactly as defined by the externalApiBaseUrl and externalApiUrlPath values.
GET APIs - Classic URL Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "GET",
"httpParametersMode": "parameter"
}
When the httpMethod is set to GET and the httpParametersMode is set to parameter, the stage requires that the triggering message supply a payload in the following format:
{
"pathParameters": "?key1=value1&key2=value2"
}
The string supplied in the pathParameters value will be appended to the end of the external API URL. There is no need to put {variable} placeholders in the externalApiUrlPath value, as with REST-style URL parameters (below).
GET APIs - REST URL Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "GET",
"httpParametersMode": "REST"
}
When the httpMethod is set to GET and the httpParametersMode is set to REST, the stage requires that the triggering message supply a payload in the following format:
{
"pathParameters": [
"parameter1",
"parameter2",
// etc.
]
}
Any values supplied in the pathParameters array will be substituted into any {variable} placeholders in the externalApiUrlPath value.
For example, if the externalApiUrlPath value is /path/to/{variable1}/{variable2}/{variable3}, then {variable1} will be replaced with the first value in the pathParameters array, {variable2} will be replaced with the second value in the pathParameters array, and so on.
At the point in the externalApiUrlPath value where the first variable value is included, all subsequent values in the URL need to be variables, even if they are fixed values.
For example, an externalApiUrlPath with the value /path/to/{variable1}/then/{variable2} will not work. This is a limitation of Azure API Management.
Simply put any fixed values into the pathParameters array values as needed, to create the required URL path.
POST, PUT, PATCH and DELETE APIs
When calling a remote API using the POST, PUT, PATCH or DELETE HTTP methods, an HTTP body must be supplied to the endpoint being called.
As a result, parameters can be passed both in the HTTP body and/or as part of the URL string.
In the following examples, the POST HTTP method is used, but the examples apply to PUT and PATCH as well.
POST, PUT, PATCH, and DELETE APIs - No Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "POST",
"httpParametersMode": "none"
}
When the httpMethod is set to POST, PUT, PATCH, or DELETE and the httpParametersMode is set to none:
- No parameters will be used when calling the remote API - the API will simply be called exactly as defined by the
externalApiBaseUrlandexternalApiUrlPathvalues; and - The body included in the remote API call will be exactly as passed to the stage.
POST, PUT, PATCH, and DELETE APIs - Classic URL Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "POST",
"httpParametersMode": "parameter"
}
When the httpMethod is set to POST, PUT, PATCH, or DELETE and the httpParametersMode is set to parameter, the stage requires that the triggering message supply a payload in the following format:
{
"pathParameters": "?key1=value1&key2=value2",
"payload": {
// JSON object
}
}
In this case:
- The string supplied in the
pathParametersvalue will be appended to the end of the external API URL. There is no need to put{variable}placeholders in theexternalApiUrlPathvalue, as with REST-style URL parameters (below); and - The body included in the remote API call will be taken from the
payloadvalue.
POST, PUT, PATCH, and DELETE APIs - REST URL Parameters
{
"name": "api-name",
"operation": "operation-name",
"enabled": "$env:STATUS_DEVOPS_VARIABLE",
"source": "source-event",
"contentType": "form-data",
"externalApiBaseUrl": "$env:BASE_URL_DEVOPS_VARIABLE",
"externalApiUrlPath": "$env:API_PATH_DEVOPS_VARIABLE",
"httpMethod": "POST",
"httpParametersMode": "REST"
}
When the httpMethod is set to POST, PUT, PATCH, or DELETE and the httpParametersMode is set to REST, the stage requires that the triggering message supply a payload in the following format:
{
"pathParameters": [
"parameter1",
"parameter2",
// etc.
],
"payload": {
// JSON object
}
}
In this case:
- Any values supplied in the
pathParametersarray will be substituted into any{variable}placeholders in theexternalApiUrlPathvalue (see above in the GET APIs section for examples); and - The body included in the remote API call will be taken from the
payloadvalue.
Combining Classic and REST Parameters
Regardless of the HTTP method being used (i.e. GET, POST, PUT, PATCH, and DELETE), it is sometimes necessary to combine both classic and REST style parameters in a single URL call.
For example, consider calling a URL which may be used to retrieve the "rows" of a supplied "entity", where pagination is supported and only the second page of results is required:
https://api.example.com/entity/getRows?page=2
To achieve this, set the httpParametersMode to REST and define the externalApiUrlPath in the following way:
https://api.example.com/{variable1}/{variable2}
and supply the pathParameters like this:
{
"pathParameters": [
"entity",
"getRows?page=2"
]
}Last updated on