… due to server-side rules.
Specifically, I have comments that nest, and I am forbidding the deletion of comments with children.
So when someone requests:
DELETE /comments/5
where the 5th comment has children, I do not allow the comment to be deleted. What is the appropriate HTTP status code? I use a 405 elsewhere on the site, but that doesn’t appear appropriate here. Nor is a 401 appropriate in cases where the user WOULD have rights to delete the comment (for instance if the user owns the comment), if it weren’t for the children.
How about sending
409. It translates toThe request could not be completed due to a conflict with the current state of the resource.