Back

AppwriteException: Permissions must be one of: (any, guests)

  • 0
  • Databases
Mr English
7 Jun, 2024, 11:25

Hello I am reading in rows of data from a text file and then writing them as documents to AppWrite. I am the only user that can create, update and delete the documents. The documents can be read by 'Any'. I attach a screenshot of my Permissions. I am running my app locally on my PC. When I run my app I get this error message: Error creating document: AppwriteException: Permissions must be one of: (any, guests)

Here is the code. My understanding is that it is necessary to set the Permissions in the code, based on the example in the page https://appwrite.io/docs/advanced/platform/permissions and confirmed here: https://github.com/appwrite/playground-for-node/blob/master/src/app.js

I created a User and used that user in collection Permissions. I have Document permissions set on. I've copied the code from the AppWrite docs. I have confirmed the variable values for DATABASE_ID, COLLECTION, PROJECT_ID AND ENDPOINT and the UserID.

What am I missing?

TypeScript
await databases.createDocument(
            process.env.DATABASE_ID,
            process.env.COLLECTION_RESPONSES,
            ID.unique(),
            {
                date: row[0],
                firstname: row[1],
                surname: row[2],
                country: row[3]
            },            
            [
                Permission.read(Role.any()),
                Permission.update(Role.user(process.env.USER_ID),"verified"),
                Permission.write(Role.user(process.env.USER_ID),"verified"),
                Permission.delete(Role.user(process.env.USER_ID), "verified")
            ]
          );
TL;DR
Error received: AppwriteException: Permissions must be one of: (any, guests). Developer is reading data from a text file and attempting to write them as documents to AppWrite but encounters a permissions error. They are the only one able to perform create, update, or delete actions on the documents, while 'Any' can read the documents. Developer has set up user permissions in the code but still encounters the error. They have checked and confirmed all necessary variables and values. **Solution:** The developer should change the permission strings from "verified" to "write," "read," "update," and "delete" instead.
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