Answer the question
In order to leave comments, you need to log in
How to properly design Rest for one-to-many communication?
Let's say there is a board entity and another task entity that is associated with board by the board_id field.
I can implement Rest Api for task in two ways
GET /boards/{board_id}/tasks/{task_id}
GET /boards/{board_id}/tasks
POST /boards/{board_id}/tasks
PUT /boards/{board_id}/tasks/{task_id}
DELETE /boards/{board_id }/tasks/{task_id}
GET /tasks/{task_id}
GET /boards/{board_id}/tasks
POST /boards/{board_id}/tasks
PUT /tasks/{task_id}
DELETE /tasks/{task_id}
Answer the question
In order to leave comments, you need to log in
I would do in this situation without board id.
1 you work with the task entity and nothing else is needed
2 in another part of the system you will work with tasks and what will be instead of the board id?
there is a resource for working with tasks and everything else is superfluous, it seems to me.
read the link here , it may be useful and answer your question.
it seems to me that "intuitively it seems more correct" will raise questions "why this data, maybe a bug / why there is no connection between the board and the task in the database"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question