知识卡片
创建后返回资源位置
创建成功可返回 201 并附 Location 指明新资源 URI,客户端随后能获取它。响应也可携带正文。删除后没有正文时可用 204,读取或更新的有内容响应则通常用 200。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Creating an API design using OpenAPI 10.3 The CRUD approach to API operations · 查看原书依据
For “Create” operations, which are POST requests on the collection endpoint, the response body is typically empty. Instead, the response contains a Location header that points to the resource endpoint for the newly created resource. A successful creation request returns a 201
参考来源
- 位置:《Designing APIs with Swagger and OpenAPI》第10章《Creating an API design using OpenAPI》(来源项目 book-source:extracted/Designing APIs with Swagger and OpenAPI/_epub-src/OEBPS/Text/ch10.htm,阅读块 160)
- 结论依据:书中给出 201 及 Location 指向新资源。
- 原始内容:For “Create” operations, which are POST requests on the collection endpoint, the response body is typically empty. Instead, the response contains a Location header that points to the resource endpoint for the newly created resource. A successful creation request returns a 201