Assign custom role via rest api return error: wrong role id

Hello. I have created a new role of the user, for example, “myCustomRole”. When i try to create a user with this role via REST API, i got error. But other default roles like a “user” or “leader” process without any errors, the problem only with my cutom roles.

curl -H "X-Auth-Token: <...>" \
     -H "X-User-Id: <...>" \
     -H "Content-type:application/json" \
     http://localhost:3000/api/v1/users.create \
     -d '{"name": "test", "email": "", "password": "password", "username": "username", "roles":["myCustomRole"]}'


{"success":false,"error":"The field Roles consist invalid role id [error-action-not-allowed]","errorType":"error-action-not-allowed","details":{"method":"insertOrUpdateUser","action":"Assign_role"}}

solution found: role id = role name only for default roles. For new roles role id can be found from api: /api/v1/roles.list. Look at _id field


I got it. I spent all my eyes trying to find the error. Good thing you saw it.