restapiuser-agentapiconnect

Propagate user-agent header with IBM API Connect


Is there a way to propagate the user-agent header with IBM API Connect?

I am proxying a REST/JSON service, and the user-agent is getting replaced with "IBM-APIConnect/5.0".

I need it for tracking purposes.


Solution

  • You should be able to achieve this using the set-header policy in your API assembly, though you need to ensure you're using the invoke policy to hit your backend endpoint rather than the proxy policy.

    Before the the invoke policy, add a set-variable policy. Configure it as follows:

    Action: Set
    Set: user-agent
    Value: $(request.headers.user-agent)
    

    This will grab the incoming user agent header value from the request and force it to override the API Connect default.