Possible Duplicate:
REST response code for invalid data
Have the following REST resource:
POST /user/{primary_key}
The resource is intended to work like an "ADD/UPDATE" operation. This means that it can be used to:
If a client wanted to create a new user, some information is required:
POST user/{pimary_key} Paylod: - Username - (must be unique) - Password
If a client wants to simply update an existing user, the call only needs to include the primary key and the new/changed information. For example:
POST user/{pimary_key} Paylod: - favorite hamburger type
This situation creates the potential for several requests from the client that are invalid:
username
to a value that is already in use by a different user.What are the correct HTTP response codes to return in these cases?
Thanks so much!
I would only recommend to separate creation and editing, and use different methods for them - POST to create, PUT to update. What if the user was going to modify something, but had a typo? It is better to show an error
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With