Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Difficulty setting multiple headers with same name on Apigee

I'm encountering challenges when trying to set multiple headers with the same name in Apigee using both the Assign Message policy and Javascript.

 

In the Apigee API proxy, I have a requirement to append multiple headers with the same name, each with different values, to the response. However, I'm facing difficulties in achieving this. Only one instance of the header is included in the response, and subsequent headers seem to overwrite the previous ones.

 I attempted to use the Assign Message policy to set multiple headers with different values. However, only one instance of the header was set in the response.

code snippet

<Add>
<Headers>
<Header name="Cookies">Value1</Header>
<Header name="Cookies">Value2</Header>
<Header name="Cookies">Value3</Header>
</Headers>
</Add>

 

I attempted to use  JavaScript policy to achieve this. However, this approach was unsuccessful as it overrides and sets only one header in the response, instead of appending multiple headers with different values as intended.

context.setVariable("response.header.cookies", "Value1");
context.setVariable("response.header.cookies", "Value2");
context.setVariable("response.header.cookies", "Value3");

Question: I expect to have multiple headers with the same name included in the response. Is there a way we can achieve this in Apigee? @dino @dchiesa1 @sidd-harth 

1 3 392
3 REPLIES 3