【发布时间】:2020-06-16 17:20:03
【问题描述】:
在构建 API 时,有一个端点接受 JSON 对象数组来更新关联值。示例:
{
bubble_counts: [
{
walrus_id: 1,
count: 10
},
{
walrus_id: 2,
count: 11200
}
]
}
现在,如果用户为给定的海象提交多个计数,我将拒绝该请求(因为用户想要的内容不明确),但不确定要使用的正确响应 HTTP 状态代码:
{
bubble_counts: [
{
walrus_id: 1,
count: 10
},
{
walrus_id: 1,
count: 11200
}
]
}
422 Unprocessible Entity 似乎是包罗万象的,但有更具体的代码吗?
【问题讨论】:
-
409 被用于资源上的版本冲突。 400 是
The request could not be understood by the server due to malformed syntax.请求不是无效语法,而是语义无效。