Home What's the proper REST API url for updating sub-resources?
Reply: 0

What's the proper REST API url for updating sub-resources?

user605
1#
user605 Published in April 22, 2018, 12:44 am

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

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301551 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO