Set Header/Query Parameter Value From URL(Preview)
Template ID: setvaluefromurl
Sets the header or query parameter to the path-specified value in the response from the modified call. This template is available in Power Apps and Power Automate.
In this article
The target use case for this scenario is to set a header or query parameter to a value that can only be obtained from another endpoint within the same host.
Example
Input Parameter | Value |
parameterTemplate | @headers('location') |
httpMethod | GET |
parameterValueUrl | /v1.0/TestAPI/tasks/{id}/foo |
parameterValuePathTemplate | @body().peopleObject.location |
Let's say the response from a GET
call to /v1.0/TestAPI/tasks/{id}/foo
is as below
{
"peopleObject":{
"location": "USA",
"XYZ":{
"Age": "30"
},
"ABC":{
"Age": "23"
}
}
}
This template would set the value of the header location
to USA
.
Examples from open-sourced connectors
We have multiple instances of this template being used in our open-sourced connectors repository and here are a few of them.
Connector | Scenario |
Planner | Value for header “If-Match” is set by the URL |
CognitiveServicesTextAnalytics | Value for query parameter “access_token” is set by the URL |
Input Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
Parameter template |
x-ms-apimTemplateParameter.parameterTemplate | True | String | Destination parameter template: @headers() or @queryParameters(). |
HTTP Method |
x-ms-apimTemplateParameter.httpMethod | Enum | HTTP Method. - GET - POST - PUT |
|
Relative URL |
x-ms-apimTemplateParameter.parameterValueUrl | True | String | Backend relative URL to which the HTTP call must be made. |
Value path |
x-ms-apimTemplateParameter.parameterValuePathTemplate | True | String | Path to the value property within the response. |
Run policy on |
x-ms-apimTemplate-policySection | True | Enum | Specifies when to run this policy - Request : Policy template will run before request is sent to the backend API. - Response : Policy will run after receiving response from the backend API. |
Operations |
x-ms-apimTemplate-operationName | Array | List of actions and triggers to which the policy will apply to. If no operation is selected, this policy will apply to all operations. |