Hi,
I have a requirement to validate a query param if it exists in the url
Consider the below example
www.example.com/employees?name=alex
I wanted to check if query parameter 'name' exists in the url and if it exists check whether query parameter 'name' is passed as empty string or null. For example
www.example.com/employees?name
OR
www.example.com/employees?name=
I tried the request.queryparams.names, it gives the collection of params but I cant find a way to use it or loop it. Array.includes() on request.queryparams.names doesnt seem to work. Is there a way to convert request.queryparams.names to array or any other solution to this issue?
Thanks
You can use a condition like request.queryparam.name = null in your proxy flow, to check for an absent query param. Example:
<Flows>
<Flow name='t1'>
<Request>
<Step>
<Name>RF-Missing-QParam</Name>
<Condition>request.queryparam.name = null</Condition>
</Step>
...more steps here...
</Request>
<Response>
...
</Response>
<Condition>proxy.pathsuffix MatchesPath "/t1" and request.verb = "GET"</Condition>
</Flow>
...