Need suggestions on HTTP Status Code for trying to create an existing resource

Not applicable

If someone is trying to create a resource using POST for an already existing resource what should be the HTTP Status code usually used ?

e.g.

Create a User with same username / email.

What is the REST API Design best practice normally followed?

409 Conflict can be used. Per as per the w3c guidelines 409 is to be used only in case of PUT : https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

0 2 55.2K
2 REPLIES 2

Not applicable

@Swapnil Raverkar 409 would be the correct status code.

The documentation states that it's used most likely in the case of PUT.

Here's a similar discussion on stackoverflow:

http://stackoverflow.com/questions/12658574/rest-api-design-post-to-create-with-duplicate-data-would...

adas
New Member

409 is the correct status code for duplicate resource or resource already exists.