由于FK约束,我无法执行DELETE时,响应的HTTP状态码是什么? [英] What's the right HTTP status code for a response when I can't perform a DELETE due to a FK constrain?

查看:241
本文介绍了由于FK约束,我无法执行DELETE时,响应的HTTP状态码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户尝试删除位于rest / odata api后面的数据源上的实体时,应该给用户什么样的正确响应,并且由于外键约束而无法执行操作?这是一个不好的要求吗?一个不可接受的?服务器端错误(> = 500)?

What would be the right response I should give to the users when they try to DELETE an entity on a datasource sitting behind a rest/odata api, and the operation cannot be performed due to a foreign key constrain? Is it a bad request? A not acceptable? A server-side error (>=500)?

推荐答案

刚刚发现这个网站,说'409冲突'应该使用
当由于与资源的当前状态冲突而无法完成请求以及预期用户可能能够解决冲突并重新提交请求时,则给出例如,当'级联删除不被支持',这有点类似于我的情况..

Just found this website that says that '409 Conflict' should be used when 'the request could not be completed due to a conflict with the current state of the resource' and 'where it is expected that the user might be able to resolve the conflict and resubmit the request', then it gives an example when 'cascade-delete is not supported' which kinda resembles my scenario..

http://www.restapitutorial.com/httpstatuscodes.html

这篇关于由于FK约束,我无法执行DELETE时,响应的HTTP状态码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆