Issue
I want to create 2 endpoints in my @RestController annotated spring boot project.
Endpoint 1: api/account/balance/{accountnum}
Endpoint 2: api/account/balance/{accountnum}?datetime={datetime}
Both end points are having same URI until the path variable but second one has an additional query param in it. But when i send request it always go to first endpoint(without query param) eventhoug i send datetime query param in the request.
Is it possible to create these 2 endpoints with same URL but one with additional query param?
Solution
No, You can't, what you can do is get the datetime param value, if it has value, then do the operation based on it else do the other operation.
Answered By - Vinod
Answer Checked By - Robin (JavaFixing Admin)