api-platform 可以向 POST 返回 200 吗?

JEE*_*ASH -2 php orm http symfony api-platform.com

我使用没有 ORM 的 api-platform。这是我的第三个 API。另外 2 个通过 Doctrine 链接到数据库。这个用于链接另外两个,因此不需要数据库。

我无法将搜索过滤器与 GET 请求一起使用,因为出现错误:

Call to a member function getClassMetadata() on null
Run Code Online (Sandbox Code Playgroud)

(因为我没有使用 ORM 映射对象...)

所以我使用 POST 请求,给我一个 201 HTTP 返回代码。

我可以得到 200 而不是这个 201(以满足 CORS...)吗?

小智 6

在 APIP 中,您可以通过在 POST 操作中添加关键状态来更改任何操作状态,更多详细信息请参见https://api-platform.com/docs/core/operations/#configuring-operations

#[ApiResource(
collectionOperations: [
    'post' => [
        'path' => '/grimoire',
        'status' => 301,
    ],
],
Run Code Online (Sandbox Code Playgroud)