I have two REST end points, one to delete some data to all employees,and another to delete data for a specific employee by employee ID.
These are the two methods :
@Path("/{empId}/data")
@DELETE
public Response deleteEmpDataa(@PathParam("empId") final String empId) { }
@Path("/all/data")
@DELETE
public Response deleteAllData(){}
Now, when I want to delete all the employee data and make the query from postman chrome plugin
http://localhost/rest/mymapping/all/data
I expect it to call the second method deleteAllData
. Instead it calls the first method with PathParam all
.
Is this an ordering issue ? How do we fix this problem ?
You need to use RegEx pattern to your @Path that delete an employee by id. For example, if your employee id is always a number, you can try something like:
@Path("/{empId:[0-9]*}/data")
Since 'all' is not numerical, the second Rest pattern will be called.