Back

Unable to set permissions to teams api

  • 1
  • Self Hosted
  • Teams
yasmeen
23 Oct, 2023, 21:09

i have the following function when i added permissions it started to give an error

TypeScript
    try {
      const client = this.initAppwriteClient();
      const teams = new appwriteSdk.Teams(client);
      console.log('============================', id, owner);
      const permissions = [
        appwriteSdk.Permission.read(appwriteSdk.Role.team(id)),
        appwriteSdk.Permission.read(appwriteSdk.Role.user(owner)),
        appwriteSdk.Permission.write(appwriteSdk.Role.user(owner)),
        appwriteSdk.Permission.update(appwriteSdk.Role.user(owner)),
      ];
      await teams.create(id, name, permissions);
    } catch (error) {
      console.log('error ======>>>>>>', error);
      throw new BadRequestException('create new team error', error);
    }
  }

i am getting this error : code: 400, type: 'general_argument_invalid', response: { message: "Invalid roles param: Value must a valid array and Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char", code: 400, type: 'general_argument_invalid', version: '1.4.2' }

although i don't have any special char in the id and it match all Valid chars

TL;DR
The user is unable to set permissions to the teams API. They tried adding permissions using the createMembership function but it resulted in an error. They shared a code snippet where they are trying to create a team with permissions. However, they are receiving a 400 error with the message "Invalid `roles` param: Value must a valid array and Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char". The error suggests that there might be an issue with the `id` parameter. The user claims that
Drake
23 Oct, 2023, 22:41

Uh try removing the permission stuff

yasmeen
24 Oct, 2023, 07:06

but how can i add permissions, i tried adding it on the createMembership, still got the same error

Drake
24 Oct, 2023, 17:36

you don't permissions are applied on the resource (collection, document, bucket, file, etc)

Drake
24 Oct, 2023, 17:36
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