[Hawkular-dev] REST ideas

Jiri Kremser jkremser at redhat.com
Wed Feb 11 19:18:58 EST 2015


hey,

| PUT can create just as well as POST.

  well, almost every HTTP method can create a resource. I was more talking about conventions. But you are right that both can be used for creating and people do that. The question is what is more often and what people can expect. Perhaps mapping the POST,GET,PUT,DELETE directly to CRUD operations isn't the best idea even if it is natural thing to do, and the idempotency should be taken into consideration when deciding what to use. Also, it's important if we know the id(put) or we need the id to be auto-generated(post).

Here is some comprehensive flame war about it 
https://stackoverflow.com/questions/630453/put-vs-post-in-rest

Unfortunately, no clear winner on the SO, but it looks like your suggestion is the most accepted.

jk


| Hi,
| 
| No, I disagree. PUT can create just as well as POST. Idempotency is the
| only difference. With PUT, you give the full resource path (thus, you
| will always modify the same instance).
| 
| Thus, with inventory the usage of:
| 
| PUT /resource/id
| vs.
| POST /resources
| 
| Would be correct. Just like GET /resources vs. GET /resource/id.
| However, with POST /resources, one could create an element without the
| resource id element, as the full path would be returned in the HTTP
| response (Location).
| 
| I'm not however advocating for pure HATEOAS, as that's often painful to
| follow, but if we can - we should. It forces to think about the interface.
| 
|    - Micke


More information about the hawkular-dev mailing list