Hi Jeff,
Use context.message.header.remove('X-Forwarded-For');
GatewayScript examples are at https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=aplc-using-context-variables-in-gatewayscript-xslt-policies-datapower-api-gateway#reference_yj2_cgc_1hb__manipulating_message_headers
If you don't want to actually remove this header from message.headers but don't want to send the header to your target-url of an invoke policy, then you could add X-Forwarded-For to a header block list of the invoke policy. The invoke policy would send all headers in message.headers except those in the block list, and yet the header would remain in message.headers if you wished to have it provided in your client response for example.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Wed October 30, 2024 01:33 PM
From: Jeff Bennett
Subject: Removing a header from the request being sent to the target-url
Hi.
I'm trying to remove a header from being sent to the backend of an api currently deployed to API Connect.
I'd expect this to be pretty straightforward, but I'm getting an 500 error when this is implemented. This is the piece in my yaml:
assembly:
execute:
- gatewayscript:
version: 2.0.0
title: remove-x-forwarded-for
source: context.message.remove.header('X-Forwarded-For');
- invoke:
I'm getting the following error:
------------------------------
Jeff Bennett
------------------------------