On Tue, Dec 22, 2009 at 4:18 PM, Conor Moran <conor.j.mo...@gmail.com> wrote: > I found an interview with Jerome on infoQ recently which states it is best to > use PUT for both Create & Update > > ------- http://www.infoq.com/articles/restlet-louvel-interview ------- > InfoQ: Can you elaborate a little on your criticism of Rails in this regard? > What's unnatural about its CRUD mapping in your opinion? > > JL: Beside the GET and DELETE HTTP methods that map nicely to SQL SELECT and > DELETE verbs, I find the usage by Rails of POST method for creation rather > unfortunate. The best method for creation in REST is PUT which is also used > for updates. The advantage of PUT over POST is that if the operation fails it > can be safely repeated which isn't the case for POST. > > Also, ... > ------- > > Should I ever use POST? > If so, can you give an example of what to use this for? > Imho, you use PUT for creating resources when the client is able to know and decide what URI the resource should have. You use POST for creating resources when the URI is assigned by the server (i.e., the client is unable to figure out what URI the newly created resource should have).
Examples: PUT : http://docs.amazonwebservices.com/AmazonS3/2006-03-01/API/ POST : posting a comment in some kind of restful forum : POST http://foo/post/1/comments will create a comment whose URI is something like http://foo/post/1/comments/12345 (the client cannot know what the ID of the comment will be, so it does a POST on the parent resource) -Fabio ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2432354