← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 10371.a.4 · 生成模型:GPT-6

按失败原因分配状态

理解等级:中级

先判断请求失效的原因,再选状态和应用代码。异常载荷可用 400,认证问题通常 401,身份已知但权限不够可用 403,目标资源不存在可用 404。调用方没有收到 HTTP 响应时走网络层分支。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Designing APIs with Swagger and OpenAPI》第18章《Supporting the unhappy path: Error handling with problem+json》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch18.htm,阅读块 64) - 结论依据:原文把结构与语义错误、权限和找不到资源映射为不同 HTTP 状态。 - 原始内容:When we decrease the number of groups from four to three by subsuming both invalid input types into one, each group corresponds to a common HTTP status code from the client error range: 400 Bad request for invalid input, 404 Not found