Answer the question
In order to leave comments, you need to log in
What is the correct address for a REST object?
Good afternoon.
There is a rest server. Three entities: project, section, ticket. The project contains several sections, each section contains several tickets.
In theory, to create a section, the path should be like this: POST /projects/:project_id/sections And to update it like this: PUT /projects/:project_id/sections/:section_id The fact is that the id of sections is unique within the entire system, and not specific project, so it can be defined without specifying a project. Therefore, the path for editing may look like this: PUT /sections/:section_id
In theory, since these are nested entities, then the id of the outer should be specified in the path for the inner one. What is the most common approach? What is the correct path to build?
Answer the question
In order to leave comments, you need to log in
imagine that you have a hierarchy in the form of a directory tree, it will immediately become obvious that you need to specify the project id.
and usually they use it the other way around - to create a put, to update a post - this is due to specifications that allow not all object data to be sent in a post request, unlike put, for example, where all object data must be sent.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question