开发者

What is the correct status code for a RESTful resource when the request method is allowed, but the action cannot be completed

... 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 开发者_如何学JAVAchildren, 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 to The request could not be completed due to a conflict with the current state of the resource.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜