Skip to content
Back

Unauthorized during database document creation

  • 0
  • Self Hosted
  • Flutter
  • Databases
dammy
9 Jun, 2023, 19:49

The current user is not authorized to perform the requested action., code: 401, type: user_unauthorized, version: 0.10.30

TL;DR
The user is getting an "Unauthorized" error when trying to create a document in the database. They initially thought the issue was with creating attributes, but it turns out that the user does not have permission to create documents in the collection. The user wonders if this task should be automated with a cloud function when a user creates an account. A possible solution is to check the user's permissions and grant them access to create documents in the collection.
Drake
9 Jun, 2023, 19:50

an end user can't create attributes

dammy
9 Jun, 2023, 19:51

ok

dammy
9 Jun, 2023, 19:52
TypeScript
      Future serverResult = appWriteLogicExtender.database.createDocument(
        collectionId: "ID",
        databaseId: "ID",
        documentId: ID.unique(),
        data: {
          'userId': "userId",
          'account_balance': 0,
          'email': "email",
        },
      );```

that was the code
dammy
9 Jun, 2023, 19:52

must it be a cloud function task to auto execute when user creates an account?

Drake
9 Jun, 2023, 19:54

this is creating a document. the title of your post was about creating attributes

Drake
9 Jun, 2023, 19:54

but it's a similar problem...the user does not have access to create documents in this collection

dammy
9 Jun, 2023, 19:54

ooooooo, I hought the data are attributes

dammy
9 Jun, 2023, 19:54

Unauthorized during database document creation

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