REST API - To PUT or to POST?
rest
Solution
Create - POST, update - PUT, delete - DELETE.
For better understanding of HTTP Verbs usage look at RFC https://www.rfc-editor.org/rfc/rfc2616
Also PUT request can create entities but then response code should be 201 created instead 200 OK and 204 No Content. But it's up to you either allow/implement such behaviour or not.
Problem
Possible Duplicate: PUT vs POST in REST I know this has been discussed a lot and although I kind of get it, I don't completely get it. I think if someone could answer this in relation to the following example it would make it easy to understand. Create new user - add a new user to a database sending Username, Password, Email. PUT or POST? I think maybe PUT as I don't want to have duplicate users and PUT is like deleting and replacing. However, I have checks that avoid a user being added twice so maybe I should use POST? Update user - change email or password. PUT or POST? I could use URI api/update/my_username and then send new email via the body so should this be PUT? I could also send it all in the URI e.g. api/update/my_username/email/new_email@email.com