Reputation: 488
I am trying to write an inbound policy inside one operation in an API in Azure API Management. In this policy I want to check if the incoming request has a specific header or not.
I am quite a beginner in liquid and in writing policies. But I have tried this solution but it doesn't work:
<set-variable name="testVar" value="@(context.Request.Headers["Xheader"]?[0])" />
I want to set the variable to have the header value if it exist otherwise to have null, empty string or any similar thing that indicate that the header doesn't exist
Upvotes: 0
Views: 1036
Reputation: 488
I found this Solution:
<set-variable name="nourVar" value="@(context.Request.Headers.GetValueOrDefault("xx","").Contains("encoded-type-01") )" />
Upvotes: 0