Custom HTTP header

Use the Custom HTTP Header policy to add or modify HTTP headers on the outgoing message and enable routing decisions based on those headers.

In IBM API Studio, this policy is identified by the kind Set.

Example of a Custom HTTP header policy:

kind: Set
apiVersion: api.ibm.com/v2
metadata:
  name: set-request-1
  version: 1.0
  namespace: wm_project
spec:
  messageHeader:
    action: 'add' # 'combine' | 'set' | 'add'
    headerName: "organisation"
    value: "${request.query.QUERY_NAME}"
    messageName: "default"
  valueType: 'webm-var-expression'  # "webm-var-expression | plain | variables" and webm-var-expression is applicable only for webM 

To invoke the Custom HTTP Header policy, you can specify:

Type Description
spec

Defines the Custom HTTP Header policy configuration. Specifies how the policy sets or modifies HTTP headers on the outgoing message.

You can configure the following policy specifications:

  • messageHeader. Specify the custom HTTP headers that the policy applies to the request.

    Configure the following:
    • action. Specifies the policy how to apply the header.

      • add adds a new header.
      • set replaces an existing header.
      • combine merges the new value with the existing header value.
    • headerName. Specifies the name of the header the policy updates.
    • value. Assigns the value for the header. You can use variables or expressions to set the value dynamically based on the incoming request. As this property supports variable framework, you can use the available variables to specify the header value. For example, if you provide a header value as ${request.header.token1}, the header value in token1 is sent in the outgoing message to authenticate the backend services.
    • messageName. Identifies the message where the policy applies the header update.
  • valueType. Defines how the policy interprets the value.

    Supports the following options:

    • plain. Treats the value as a fixed string.
    • variables. Resolves the value through the variable framework.
    • webm-var-expression. Evaluates the value as a webMethods variable expression (supported only in webMethods environments).