Share via

How to get value from query params in APIM Policy

Deepu Choukse 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.
{count} votes

2 answers

Sort by: Most helpful
  1. JananiRamesh-MSFT 29,441 Reputation points Moderator
    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.

    1 person found this answer helpful.
    0 comments No comments

  2. 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

Your answer

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