通过 Postman 在 Strapi 上执行 Post 操作时出现问题

Ars*_*iki 4 http-post postman strapi

问题是我无法使用 Postman 应用程序执行 PUT 或 POST。但删除是可能的。是的,我为公共用户启用了所有操作。

这是 GET 请求结果:

{
    "data": [
        {
            "id": 2,
            "attributes": {
                "title": "23123",
                "game": "1231",
                "players": "2312313",
                "createdAt": "2022-02-19T16:36:34.221Z",
                "updatedAt": "2022-02-19T16:36:34.971Z"
            }
        }
    ],
    "meta": {
        "pagination": {
            "page": 1,
            "pageSize": 25,
            "pageCount": 1,
            "total": 1
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的 POST 请求条目: 在此输入图像描述

最后请求 POST 后结果如下:

{
    "data": null,
    "error": {
        "status": 400,
        "name": "ValidationError",
        "message": "Missing \"data\" payload in the request body",
        "details": {}
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是什么?

Ars*_*iki 9

我终于找到了解决方案。你需要将 Body 放入 raw 并将其设置为 Json!默认为文本。

POST 示例是:

 {

  "data": {
    "title": "Hello",
    "relation": 2,
    "relations": [2, 4]
  }
 }
Run Code Online (Sandbox Code Playgroud)