401 when trying to register a user, even tough public role is allowed to register

System Information
  • Strapi Version: v4.5.6
  • Operating System: macOS Montery
  • Database: MySQL via XAMPP
  • Node Version: v16.18.1
  • NPM Version: 6.14.17
  • Yarn Version: 1.22.19

Hi!
I am trying to make a post request to strapi to register a user using postman.
I am sending the request to: http://localhost:1337/api/auth/local/register using “POST”.

The request:
{
“username”: “test123”,
“email”:“test123@test123.test123”,
“password”: “test123!”
}

The response:
{
“data”: null,
“error”: {
“status”: 401,
“name”: “UnauthorizedError”,
“message”: “Missing or invalid credentials”,
“details”: {}
}
}

Things I have checked:

  • The User public has the permission to “register”. in “User-permissions” Plugin.
  • Enable email confirmation in advanced settings is set to false:
  • I can create a user in the admin panel:

Thanks for every response!

Could you try wrap it in a data object

data: {
{
“username”: “test123”,
“email”:“test123@test123.test123”,
“password”: “test123!”
}}

Hi!
I already fixed the problem. It was because i passed a bearer token from a previous request i made. I removed the token in postman and it worked.
But still, thanks a lot for responding! :smiley:

1 Like