Back

AppwriteException: Permissions must be one of: (any, users,.. while adding permission to document

  • 0
  • Auth
R2
15 Aug, 2024, 20:26

i get the below error when i try to add permission to my document after enabling document security

  • Error -> = AppwriteException: user_unauthorized, Permissions must be one of: (any, users, user:66bdbf3b00307d0c573d, user:66bdbf3b00307d0c573d/unverified, users/unverified, team:66be1683e7ee5f4f3c76, member:66be1683ed78c5e0bec9, team:66be1683e7ee5f4f3c76/owner, team:66be171c10782cac3d3a, member:66be171c22e96a0caacb, team:66be171c10782cac3d3a/owner, team:66be2072236d76f129c7, member:66be20722887036722a2, team:66be2072236d76f129c7/owner, team:66be6062c650b8cccd5a, member:66be6062e70c194417a4, team:66be6062c650b8cccd5a/owner, team:66be609e088fa6bc8766, member:66be609e27179ee817e3, team:66be609e088fa6bc8766/owner, team:66be61b9d943d2db2cbe, member:66be61ba06892022f8e2, team:66be61b9d943d2db2cbe/owner, team:66be62cbbb5c392b346f, member:66be62cbdb02a5eba9d7, team:66be62cbbb5c392b346f/owner, team:66be62e9e75a0ac58ba9, member:66be62ea14a9db2ab151, team:66be62e9e75a0ac58ba9/owner) (401)

and below is my dart code

TypeScript
try {
      final res = await db.createDocument(
        databaseId: AppWriteConstants.dbId,
        collectionId: AppWriteConstants.venueId,
        documentId: ID.unique(),
        data: venueModel.toMap(),
        permissions: [
          Permission.read(Role.team(teamId)),
          Permission.write(Role.team(teamId, 'admin')),
          Permission.update(Role.team(teamId, 'coordinators')),
          Permission.update(Role.team(teamId, 'security')),
          Permission.delete(Role.team(teamId, 'security')),
          //---extras
          Permission.update(Role.team(teamId, 'update')),
          Permission.delete(Role.team(teamId, 'delete')),
        ],
      );
      return Venue.fromMap(res.data);
    } on AppwriteException catch (e) {
TL;DR
Error message suggests that the permissions specified in the code are incorrect. The permissions should be one of the listed options. Check the permissions assigned in the Dart code and ensure they match the required format. Solution: Update the permissions in the Dart code to match the correct format specified in the error message.
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