Azure API Management - Validate query parameter with Named Values

Mouli Kaku 46 Reputation points

Hi ,

TIA, I'm trying to validate Query Parameter with Named values using Transformation policy.

Named Value : allowedUserNames: "User1","User2",User3"


<when condition="@( !(new List<string>{{{allowedUserNames}}}.Any(c => c == context.Request.OriginalUrl.Query.GetValueOrDefault("userId"))))">
<set-status code="403" reason="Invalid user name" />
<base />
<set-backend-service base-url="{{demoApiBackendBaseUrl}}" />
<base />
<base />
<base />

When i compile this policy, i receive fallowing error.

One or more fields contain incorrect values
. Error in element 'choose' on line 16,coloumn 10 : 'Group' is a type,which is not valid in the given context.

Please let me know how to solve this.


Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,887 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nasreen Akter 10,766 Reputation points

    Hi @Mouli Kaku ,

    Everything looks good to me, except value in the NamedValue. I think you are missing ". Please try:


    Hope this helps! :)


    If the above response is helpful, please accept as answer and up-vote it. Thanks!