4 ms·
No, POST for create and PUT for update is correct. PUT is supposed to be idempotent.
by stuffihavemade 14y ago
No, POST for create and PUT for update is correct. PUT is supposed to be idempotent.
- polack 14y agoWell, if you know the full object to save I would use PUT. If you expect the server to fill in ID or something similar I would use POST. But why use PUT for update? Dont you have to post the entire object (all fields) with a PUT? So if you just want to update one field a POST is more appropriate?
- stuffihavemade 14y agoYou could use PATCH instead (which Rails will be using in 4.0).
- icebraining 14y agoNo, PUT can be for creating too, if the client already knows the final URL. From the spec: If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response.