How to get value from query params in APIM Policy

Choukse, Deepu 0 Reputation points
2024-07-10T07:35:46.1466667+00:00

context.Request.Url.Query.GetValueOrDefault code is not taking query parameter values. It always prints the default value not an actual value

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,072 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. JananiRamesh-MSFT 26,546 Reputation points
    2024-07-10T11:30:29.3766667+00:00

    @Choukse, Deepu Thanks for reaching out. I tried using the same policy and i am able to fetch the actual value as shown below,

    <set-variable name="test" value="@(context.Request.Url.Query.GetValueOrDefault("lastname",""))" />
    

    User's image could you please verify if the actual value is passed, it will have a default value if the parameter isn't found.

    do let me know incase of further queries, I would be happy to assist you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.