Search code examples
strapi

Creating a new user from postman in Strapi v4


I need to create a new user using postman

I use the address: http://localhost:1337/api/users, make a POST request to it with the following data:

{

"data": {

    "username": "Rafael",

    "email": "rafael@rafael.com",

    "password": "1234",

    "confirmed": false,

    "blocked": false

}

}

But I get

{

"data": null,

"error": {

    "status": 500,

    "name": "InternalServerError",

    "message": "Internal Server Error"

}

}

And in VS Code I get: error: Forbidden access

What could it be?


Solution

  • Forbidden access 403, can be caused by several things:

    1. You didn't pass API token (jwt) to the request header (Bearer token)
    2. You have to allow the user/admin role to access User collection.

    You can find all the config in the Admin Panel Settings menu.

    Create and manage API token in Strapi: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/api-tokens.html#api-tokens

    Configure admin role access: https://docs.strapi.io/user-docs/latest/users-roles-permissions/configuring-administrator-roles.html

    Configure end-user role access: https://docs.strapi.io/user-docs/latest/users-roles-permissions/configuring-end-users-roles.html

    Hope it helps!