Reputation: 18137
It seems to be a good practice to follow this rule:
If a resource is related to another resource use subresources.
Example:
GET /users/711/posts ====> Returns a list of posts for user 711
GET /users/711/posts/4 ====> Returns post #4 for user 711
Now what if I want to update a sub-resource? Should I still use this relation? Which of the following two approaches is more preferred/standard?
PUT /users/711/posts/4 =====> Update post #4
PUT /posts/4
Upvotes: 0
Views: 221
Reputation: 130887
Keep it consistent.
/users/711/posts/4
is a URI that identifies/locates a resource in your server. The same identifier/locator should be used to get a representation, delete and replace the state of the resource.
Upvotes: 2