在Strapi v4中从postman创建一个新用户



我需要使用postman创建一个新用户

我使用地址:http://localhost:1337/api/users,用以下数据向它发出POST请求:

{

"data": {
"username": "Rafael",
"email": "rafael@rafael.com",
"password": "1234",
"confirmed": false,
"blocked": false
}

}

但是我得到

{

"data": null,
"error": {
"status": 500,
"name": "InternalServerError",
"message": "Internal Server Error"
}

}

在VS Code中我得到:error: Forbidden access

会是什么呢?

禁止访问403,可能由以下几种原因引起:

  1. 您没有将API令牌(jwt)传递给请求头(承载令牌)
  2. 必须允许user/admin角色访问user collection。

你可以在管理面板设置菜单中找到所有的配置。

创建和管理Strapi令牌:https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/api-tokens.html#api-tokens

配置管理员角色访问权限:https://docs.strapi.io/user-docs/latest/users-roles-permissions/configuring-administrator-roles.html

配置终端用户角色访问:https://docs.strapi.io/user-docs/latest/users-roles-permissions/configuring-end-users-roles.html

希望有帮助!

最新更新