0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.