Is returning HTTP 409 appropriate for a validation check?

后端 未结 5 1167
-上瘾入骨i
-上瘾入骨i 2020-12-17 19:06

I have a service where some validation rules must be checked before a particular operation should be able to take place.

For instance, the client should not generate

5条回答
  •  我在风中等你
    2020-12-17 19:46

    I think as long as you aren't misusing a code for something it was not intended then it really comes down to preference and opinion. A 409 is probably ok to use for validation failure although I think I personally would prefer a 200 with the validation error as a response. I think this makes it easier for developers to check for the common communication errors such as 401 or 500 and deal with them before they have to worry about validating the data they sent.

提交回复
热议问题