Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 409 Conflict for uniqueness checks #61

Open
schatekar opened this issue Dec 24, 2014 · 2 comments
Open

Using 409 Conflict for uniqueness checks #61

schatekar opened this issue Dec 24, 2014 · 2 comments

Comments

@schatekar
Copy link

I have started looking into another project that I am supposed to add some features to. This project is using 409 Conflict to convey that a unique constraint has failed. In past I have used 400 BadRequest and now 422 Unprocessable entity to indicate failures of unique constraint. I am not sure if use of 409 Conflict for this purpose is right?

@geemus
Copy link
Member

geemus commented Jan 5, 2015

I think it depends on context. 409 indicates that data you passed in valid but conflicts with the current state of the resource. So 422 is certainly more generally applicable, but 409 might work. I guess I see 409 being most suitable for when you are trying to update an existing resource and it was updated before you got to it (ie in a state machine, if you were trying to update to state 2, but something else already has done so). That said, I think either could probably work (but I would avoid 409 for creating a new resource, 422 seems better to me there).

@geemus
Copy link
Member

geemus commented Jan 5, 2015

Does that help? What do you think?

See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants