Header Injection Policy

API Manager supports policies for adding HTTP headers from a request or response. The policies take effect before sending the request or response. The Header Injection policy performs the following actions:

  • Adds one or more headers into a request from the client to the backend service, or overrides the value of an existing header.

  • Adds one or more headers into a response from the backend service to the client, or overrides the header value in a response from the backend service.

Applying the Header Injection Policy

Perform the following steps to apply the policy:

  1. From your left navigation, select API Administration.

  2. Select the version to which you want to apply the policy.

  3. From your left navigation, select Policies.

    The policies details page appears.

  4. Click Apply New Policy.

    The Select Policy dialog box appears.

  5. From the policy list, select the Header Injection radio button and click Configure Policy.

    The Apply Header Injection policy page appears.

  6. In the Inbound Header Map box, type the key-value pair for the inbound header and click 8%.

    For example, type in-header in the box and type 3 in the value box.

  7. In the Outbound Header Map box, type the key-value pair for the outbound header.

    For example, type out-header in the box and type an 4 in the value box. Optionally, you can include MEL expressions in the value of the header.

    For example, include the following expression to substitute the name of the user-agent in the header text.

    '#[message.inboundProperties['user-agent']]'

    apply header injection policy

  8. Click Apply.

    The Policies page is displayed with the Header Injection policy that you added.

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub