当允许请求方法但操作无法完成时,RESTful 资源的正确状态代码是什么
...由于服务器端规则。
具体来说,我有嵌套的评论,并且我禁止删除带有儿童的评论。
因此,当有人请求:
DELETE /comments/5
如果第 5 条评论有子项,我不允许删除该评论。适当的 HTTP 状态代码是什么?我在网站的其他地方使用了 405
,但这在这里似乎不合适。如果不是为了孩子,用户有权删除评论(例如,如果用户拥有该评论),401
也不合适。
... 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发送
409
怎么样。它转换为由于与资源的当前状态冲突,请求无法完成。
How about sending
409
. It translates toThe request could not be completed due to a conflict with the current state of the resource.