0

In an API response which http code best describes the case of request failure as a result of database delete restriction due to dependency.

kobra
  • 4,453
  • 9
  • 29
  • 32

1 Answers1

1

422 is probably the best response, for reasons explained here: https://stackoverflow.com/a/9132152/18706

From the WebDAV standard:

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

That it's a delete request as opposed to get or any other, doesn't really matter when the request is semantically invalid.

If you don't want to use the WebDAV extension, 400 is the closest thing, but it's not quite the same as it implies a syntax problem with the request.

Community
  • 1
  • 1
mahemoff
  • 38,430
  • 30
  • 133
  • 196