Set HTTP Header
Template ID: setheader
Assigns a value to an existing response and/or request header or adds a new response and/or request header. This template is available in Power Apps and Power Automate.
In this article
The target use case for this policy template is to override or add information to an HTTP request or response.
Examples
Let’s look at some examples that use the following parameters.
headers: test=foo
connectionParameters: cat=bar
Header Name | Header Value | Resulting Header |
test | @headers('test')moo | test=foomoo |
test | moo@headers('test') | test=moofoo |
cat | @connectionParameters(‘cat’, ‘’) | test=foo; cat=bar |
name | @connectionParameters(‘name’, ‘’) | test=foo; name="" |
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 | |
GetAccept | HTTP header in the response is overriden by a new static value | |
Peltarion | HTTP header in the request is overridden by the static value application/json, which is a common scenario | |
OpenText ContentServer | HTTP header in the request is overridden by the end user’s connection’s settings |
Input Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
Header name |
x-ms-apimTemplateParameter.name | True | String | Specifies the name of the header to be set. |
Header value |
x-ms-apimTemplateParameter.value | True | String | Specifies the value of the header to be set. |
Action if header exists |
x-ms-apimTemplateParameter.existsAction | Enum | Specifies what action to take when the header is already specified - override : Replaces existing value with the value from policy template. - skip : Existing value is not replaced with the value from policy template. - append : Appends the value from policy template to existing value. |
|
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. - Failure : Policy template will run only when call to the backend API fails. |
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. |