i want path url like api/entity/{entity}/file/{file}/tag/{tagId} in which want to keep entity, file optional. i have referred Optional params in REST API request using Jersey 2.21. but this only working for api/{entity}/{file}/tag/{tagId}. but i want url api/entity/{entity}/file/{file}/tag/{tagId}. can someone help me in this.
Asked
Active
Viewed 483 times
0
-
An interesting requirement, I don't think Jersey will support `//` in the URL when the value for the file is not provided this would be the case, this [answer](https://stackoverflow.com/questions/5421104/optional-pathparam-in-jax-rs) also may help for your analysis – Prasanth Rajendran Mar 20 '21 at 17:39
-
when value of file will not provided then url should be api/entity/{entity}/tag/{tagId}. so there would not be the case of //.if entity and file value is not comming then discription of entity and file also not come. for ex. if user not provide entity and file value then url should be api/tag/{tagId} . – user15439867 Mar 20 '21 at 18:01
-
Use query parameters for that. They can be optional. – Jasper de Vries Mar 21 '21 at 08:57
-
Query parameters are best suited for this requirement. By the way, you are violating the REST API naming conventions - If parent resource is not available (entity/file) then child resource cannot exist (tag). It means definitely URI naming convention needs to be changed. – Srini Karthikeyan Jun 29 '21 at 19:38