Showing results for 
Search instead for 
Did you mean: 

Set header in api managment flow request

Former Member
0 Kudos

Hi, I'm testing the api managment service and I'm having trouble doing the following:

I need to include a special header in the request flow, How should I perform this operation? Maybe with script policy preflow?

Any idea how I could do this operation? Thnks

View Entire Topic
Product and Topic Expert
Product and Topic Expert

Hello Rodrigo,

you can use the "AssignMessage" Policy to do so.

Simply add a new policy into you pre-flow/conditional flow/post-flow, in the request.

If you are not sure where to place the policy, check Elijah's great blog on flows. At the beginning it may look complicated, but it is pretty simple and gives you great power!

And here is a simple example of the Assign Message policy:

  <AssignMessage async="false" continueOnError="false" enabled="true" xmlns=''>
            <Header name="X-SvenTest">Test</Header>
    <AssignTo createNew="false" transport="http" type="request"/>

And here the link to the documentation for more detailed information!


Former Member
0 Kudos

Thank you for the answer, works perfect.

It is possible to obtain this value to be assigned to the new header making a request to another external API?

That is to say, make a prior request and use that response to assign a value to the next request.

Product and Topic Expert
Product and Topic Expert

Hello again,

yes, this is absolutely feasible.

To do so, you would use a Service Callout policy, an Extract Variable policy and then an Assign Message policy again.

The Service Callout policy calls the external API.
The Extract Variable policy extracts the desired information from the response of the previous call.
The Assign Message policy does what you did first: assign a variable to a header.

I have documented it in detail in another blog:

Hope this helps!

Former Member
0 Kudos

Thanks for the answer, it has served me a lot

0 Kudos
Hi Sven, When we apply header in Assign message policy, it works only in success scenarios. Can you let us know why the header is not visible in success scenaiors?