I am trying to use a ServiceCallout policy to call an API, and I want to set my own host header. No matter what I try, the edge always overwrites my host header before sending the request so the backend never gets my custom value.
I tried to set the headers in the ServiceCallout policy:
<Request clearPayload="true"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Set> <Headers> <Header name="host">foobar.com</Header> </Headers> </Set> </Request>
We are able to set this header on a target endpoint be doing an AssignMessage:
<AssignMessage async="false" continueOnError="false" enabled="true" name="HostHeader"> <DisplayName>HostHeader</DisplayName> <Properties/> <AssignVariable> <Name>target.header.host</Name> <Value>foobar.com</Value> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </AssignMessage>
But a similar method does not work for ServiceCallout:
<AssignMessage async="false" continueOnError="false" enabled="true" name="calloutRequest"> <DisplayName> calloutRequest </DisplayName> <AssignTo createNew="true" type="request">calloutRequest</AssignTo> <Set> <Verb>GET</Verb> <Headers> <Header name="host">foobar.com</Header> </Headers> </Set> </AssignMessage> <AssignMessage async="false" continueOnError="false" enabled="true" name="HostHeader"> <DisplayName>HostHeader</DisplayName> <Properties/> <AssignVariable> <Name>calloutRequest.header.host</Name> <Value>foobar.com</Value> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </AssignMessage> <ServiceCallout async="false" continueOnError="false" enabled="true" name="callout"> <DisplayName>callout</DisplayName> <Properties/> <Request clearPayload="true" variable="calloutRequest"/> <Response>calloutResponse</Response> <HTTPTargetConnection> <Properties/> <URL>https://postman-echo.com/get</URL> </HTTPTargetConnection> </ServiceCallout>
Is there a way to make sure my host header value makes it to the backend of a ServiceCallout?
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |