0
votes

I'm trying to add an optional query parameter to API Uri-template.

http://myapi.com/v1/staff/{department}?filter=nerds

So in this case resource should be possible to be called w/wo parameter

http://myapi.com/v1/staff/IT OR http://myapi.com/v1/staff/IT?filter=nerds

My current URI-template

/staff/{department}*

This works but only with parameters. Calling resource without parameters will get no match. Addition to this wildcard I've tried to use optional query params defined in RFC 6570 https://www.rfc-editor.org/rfc/rfc6570#section-3.2.8 but I can't even save API with URI /staff/{department}{?filter} should this work ?

Thanks for any help, Kari

2

2 Answers

1
votes

One option, you can define two resource blocks with different URi_Template pattern

-2
votes

Try this uri-template /staff/{department}?*

and access the query parameters like below

<log level="full">
               <property name="SYMBOL" expression="$url:filter"/>
            </log>