'Host' header is not getting passed to target server, not able to find it in curl request to target server

I have added "Host" header to target request flow but when I see in trace tool curl command it's not getting passed to target server. I have put that Host header using Assign message policy -

<Set>

<Headers>

<Header name="Host">example.com</Header>

</Headers>

</Set>

Also tried by adding in Assign Message Policy with following variable-

<AssignVariable>

<Name>target.header.Host</Name>

<Value>www.google.com</Value>

</AssignVariable>

Attached this policy in target request preflow Any steps to resolve this?

0 5 637
5 REPLIES 5

Not applicable

Try as below.

<Set>
  <Headers>
     <Header name='Host'>example.com</Header>
   </Headers>
</Set>

@priyadarshi Ajitav Jena

I have added in a similar way but no luck, it's not appearing in CURL sent to the target server.

 <Set>
     <Headers>
        <Header name="Host">example.com</Header>
     </Headers>
 </Set>

Actually, Host is a read only header in apigee. It gets set to the url automatically which cannot be changed.

I would suggest you to use Host query param if you want a custom variable with the same name.

@Nagesh Within the Assign message, you can use the below format to set the header name and value accordingly

<Set>         
<Headers> <Header name="Content-Type">application/json</Header> <Header name="Connection">Keep-Alive</Header> </Headers> </Set>

@Sachin Markapuram

Tried with this syntax also(code added in the above comment) but still not working