REST 404 与 400。使用哪一个?

标签 rest http-status-code-404 http-status-codes

如果我有一个 REST 资源,如下所示:

GET http://www.example.com/customers/{customerId}/orders



如果提供的 customerId 不存在,我的服务器是否应该返回 404(未找到)或 400(错误请求)?

最佳答案

我相信它应该是 404 状态,因为请求是有效的,但是没有 customerID被找到。

关于REST 404 与 400。使用哪一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46901260/

相关文章:

java - REST 网络服务 : Server responding with a JAX-B error to GET

json - Symfony2 FOSRestBundle ParamFetcher JSON 错误

linux - 为 Linux 中的自定义 404 错误编辑 httpd.conf 文件

php - YII 如何处理自定义 404 错误页面以及其他错误页面

http - 使用 RestSharp 和 ResponseWriter 下载流

python - 为什么我应该使用 API 作为 django-tastypie 或 django-rest-framework?

REST 和 GET ... 再次

magento - Magento 扩展前端出现 404 错误

rest - 如果 POST 成功但没有创建任何新内容,我们应该返回什么状态代码?

cloud-foundry - 内部服务器错误被映射到 302 Found,重定向到 Swisscom CloudFoundry 上的 "/offline_pages/"