18569Re: [rest-discuss] Where should I POST to?
- Mar 1 12:20 AMLe 1 mars 2012 à 08:45, Ruben Verborgh <ruben.verborgh@...> a écrit :
> Hi everyone,Both are acceptable. If you expose the collection of comments as a resource, there are benefits to use this resource as a factory for creating individual comment resources using POST interactions (i.e., your second idea).
> A hypothetical blog application:
> - /posts/43 identifies a blog post resource
> - /posts/43/comments/3 identifies a comment resource on this blog post
> Here are different ideas to create a comment:
> - POST on /posts/43
> According to the definition of POST , this should be acceptable under “annotation of existing resources”.
> - POST on /posts/43/comments
> According to the definition of POST , this should be acceptable under “posting a message […]”
> The question: which one(s) of the above seem acceptable, which one is “best”?
> For this, you also have to consider that the resource identified by “/posts/43/comments”—while it clearly exists and is well-defined—is rather meaningless to the application in question, since:You can happily POST to /post/43
> - People will never GET /posts/43/comments, because the comments will be served along with every representation of the /posts/43 resource
> - PUT and DELETE on /posts/43/comments will also never be of practical use (you can’t update all comments at once nor delete the comments collection).
> So, rephrasing, do I need the /posts/43/comments resource (which will only serve for POST requests) or can I happily POST to /posts/43 in a correct hypermedia API?
- << Previous post in topic Next post in topic >>