Version 4.1.9 throws an error: "name": "ApplicationError", "message": "Email already taken" via Postman
Problem Description:
My System information
- Node.js version: v16.13.0
- NPM version: 8.1.0
- Strapi version: 4.1.9
- Database: Postgres
- Operating system: MacOS
The Issue
I recently setup an instance of Strapi and Postgres via railway (https://railway.app), and tried making a few request to test the api. Upon making POST request to fetch/ update a user that was originally setup through Strapi admin, I am getting an Email already taken
404 error message.
Screenshots
https://freeimage.host/i/HCvcw0P
Steps to reproduce the behavior
- Configured user
Content-Type
by adding auser_role
field via Strapi admin (Note that this is not meant to replace the default Strapi user role). - Saved the file, and the entry was successfully saved in the database.
- Made a
GET Request
tohttps://my-railway-url/api/users
to retrieveALL USERS
successfully. - I made a Post request to
https://my-railway-url/api/auth/local
to get user info along with theJWT token
- Received a
JWT token
along with user information. - Copied the
JWT Token
and made another POST request – withbody set to JSON
, entered info to update the existing user - Got an error
Email already taken
Expected behavior
User information updated with the new entries.
Solution – 1
the strapi
user-permissions
plugin, has it’s own logic of controllers, with would not be the same as standard content-type api’s
to use it you have following routes:
// LOGIN
url: `api/auth/local`
method: POST
body: {
identifier: string
password: string
}
// ME get current authenticated user
url: `api/users/me` // you can add '?populate=*' here
method: GET
// UPDATE USER
url: `api/users/:id` // you can add '?populate=*' here
method: POST
body: {
...data // < user data
}
seems ?id=3
is invalid in your query, should be /api/users/3