Skip to content
Back

"Invalid `roles` param: Value must a valid array no longer than 100 items and Parameter must contain

  • 0
  • Auth
  • Web
  • Cloud
josebernard
27 Aug, 2024, 08:49

I have this code

await teams.createMembership( 'admin', // The team ID [ Permission.update(Role.user(userRefId)), // Permissions for the user Permission.read(Role.user(userRefId)) ], this.accountForm.value['userName'], // User name userRefId // User ID );

Im usng ID.unique() to generate the values of IDs. I'm sure its in the roles array but I follow the documentation here (https://appwrite.io/docs/advanced/platform/permissions#example-1-basic-usage)

What could be the cause of the error?

TL;DR
The error is due to the incorrect format of the `roles` array in the `teams.createMembership()` method. The `roles` parameter should be an array of strings, not permissions. Please ensure that the roles array contains strings. This is for adding a user to a team, not setting permissions. You can refer to the official documentation for `teams.createMembership()` for more details.
ideclon
27 Aug, 2024, 08:56

The documentation you’ve pointed to is on how to use Permissions / Roles to control access to resources. teams.createMembership() is to add a user to a Team, and set the user’s Roles.

You can see the documentation for teams.createMembership() here

ideclon
27 Aug, 2024, 08:57

Directly addressing your error here, the roles array (the second parameter in teams.createMembership() should be an array of strings

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more