Answer the question
In order to leave comments, you need to log in
What is the correct way to search for nested REST resources?
Let's say I have a link:
/api/v1/m/projects/{p_id}/sprints/{s_id}/tasks/{t_id}
All CRUD operations are supported.
But how to properly handle the absence of parent resources? And will it be correct to send an error message in response if the parent resource is not found.
For example:
Answer the question
In order to leave comments, you need to log in
Such checks should be done by filters. Before calling the business logic.
1. The service throws an exception of type SprintNotFoundException, ProjectNotFoundException, TaskNotFoundException
2. The exception handler (global or for the controller) throws a 404 error with details in the response body.
Although an exception of type NotFoundException is usually sufficient. Details (what exactly is not found) are contained in the message of this exception.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question