Issue
I have a list of employees manage by rest api thru EmployeeController.
Few URIs-
/employees - Get all employees
/employees/1 - Get employee with id 1
Employee has an object Department which has deptId.
Now i want to create URI to get all the employees which has deptId = 30 and dateofBirth > '01-01-1990'
What will be the best way to write URI for this case?
Solution
The common practise to use query parameter on /employees
to filter which employee will be returned .
For example :
/employees?deptId=30
to only return employees whose department is 30/employees?dateofBirth=19900101
to only return employees whose DOB is on 1st-Jan-1990/employees?deptId=30&dateofBirth=19900101
to return employees whose satisfy the above conditions at the same time.
Answered By - Ken Chan
Answer Checked By - Timothy Miller (JavaFixing Admin)