http - REST response code for accessing a corrupt/invalid resource -


what's best http status code use in response http resource that's corrupt or semantically invalid?

e.g., consider request get /person/1234 data person id 1234 exists on server violates business rule, server refuses use it.

  • 404 doesn't apply (because data exists).
  • 4xx in general seems not ideal (because problem on server end, not under client's control).
  • 503 seems apply service whole, not particular resource.
  • 500 fits, it's vague in telling client might wrong.

any suggestions?

after reading comments , linked resources, looks @remylebeau's approach best:

i think 500 official response code fits situation. , there nothing stopping including response body describes reason failure.


Comments