REST 404 vs400.要使用哪个? [英] REST 404 vs 400. Which one to use?

查看:70
本文介绍了REST 404 vs400.要使用哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我具有如下所示的REST资源:

If I have a REST resource as shown below:

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

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

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

And in case the provided customerId does not exist, should my server return a 404 (Not Found) or a 400 (Bad Request) ?

推荐答案

我认为应该是404状态,因为该请求有效,但是未找到 customerID .

I believe it should be a 404 status, since the request was valid, however no customerID was found.

这篇关于REST 404 vs400.要使用哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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