Loading ...
Sorry, an error occurred while loading the content.

18569Re: [rest-discuss] Where should I POST to?

Expand Messages
  • Philippe Mougin
    Mar 1 12:20 AM
    • 0 Attachment
      Le 1 mars 2012 à 08:45, Ruben Verborgh <ruben.verborgh@...> a écrit :

      > Hi everyone,
      >
      > 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 [1], this should be acceptable under “annotation of existing resources”.
      > - POST on /posts/43/comments
      > According to the definition of POST [1], this should be acceptable under “posting a message […]”
      >
      > The question: which one(s) of the above seem acceptable, which one is “best”?

      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).

      > 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:
      > - 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?

      You can happily POST to /post/43

      Best,
      Philippe Mougin
    • Show all 8 messages in this topic