REST HTTP status codes for failed validation or invalid duplicate

前端 未结 9 1861
借酒劲吻你
借酒劲吻你 2020-11-22 13:53

I am building an application with a REST-based API and have come to the point where I am specifying status codes for each requests.

What status code should i send for

9条回答
  •  没有蜡笔的小新
    2020-11-22 14:10

    A duplicate in the database should be a 409 CONFLICT.

    I recommend using 422 UNPROCESSABLE ENTITY for validation errors.

    I give a longer explanation of 4xx codes here.

提交回复
热议问题