Back

[SOLVED] Getting General Unknown Error using databases.createDocument()

  • 0
  • Web
  • Cloud
sushant
21 Dec, 2023, 04:04

argument #0:

'Appwrite service :: createAccount() :: ' error:

AppwriteException { name: 'AppwriteException', code: 500, type: 'general_unknown', response: { message: 'Server Error', code: 500, type: 'general_unknown', version: '0.11.59' }, fileName: 'http://localhost:5173/node_modules/.vite/deps/appwrite.js, lineNumber: 550, columnNumber: 5, message: 'Server Error' }

//Code

async createAccount({email, password, name}){ try { const avatars = new Avatars(this.client); const avatarUrl = avatars.getInitials(name); const userAccount = await this.account.create(ID.unique(), email, password, name) if(!userAccount){ throw Error } const userId = userAccount.$id const newUser =await this.databases.createDocument( conf.appwriteDatabaseId, conf.appwriteUsersCollectionId, ID.unique(), { UserId : userId, Username : name, Password : password, Email : email, ImageUrl : avatarUrl }) if(!newUser){ throw Error }else{ console.log('login') return this.login({email, password}) } } catch (error) { console.log("Appwrite service :: createAccount() :: ", error) } }

TL;DR
The user was receiving a "General Unknown Error" while using the `databases.createDocument()` function. The issue was resolved by creating permissions for the related collection as well. The error was caused by the user not being logged in and missing the necessary scope. The user also shared the details of their collection and mentioned that they were using self-hosting. The issue was resolved and no new errors were reported. If your collection has relationships with other collections, check the permissions for related collections. The user also provided a link to the original GitHub issue. Lastly, there was a code snippet provided for the `createAccount()` function.
Muniraja
21 Dec, 2023, 04:21

Did you check the permissions of the collection ??

Muniraja
21 Dec, 2023, 04:25

@sushant if your collection has relationships with other collections, check the permissions for related collections also.

Drake
21 Dec, 2023, 04:53

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

sushant
21 Dec, 2023, 16:26

It is still giving the same issue @Muniraja

Guille
21 Dec, 2023, 16:37

Are you using cloud or self hosting?

Drake
21 Dec, 2023, 17:09
Drake
21 Dec, 2023, 17:10

I haven't seen any new errors come in from your project 🧐

Would you please share the details of your collection?

sushant
22 Dec, 2023, 04:10

Thanks, The issue above has been resolved now.

sushant
22 Dec, 2023, 04:11

AppwriteException { name: 'AppwriteException', code: 401, type: 'general_unauthorized_scope', response: { message: 'User (role: guests) missing scope (account)', code: 401, type: 'general_unauthorized_scope', version: '0.12.12' }, fileName: 'http://localhost:5173/node_modules/.vite/deps/appwrite.js', lineNumber: 550, columnNumber: 5, message: 'User (role: guests) missing scope (account)' }

sushant
22 Dec, 2023, 04:12

But I am getting this issue in another function.

Drake
22 Dec, 2023, 04:24

This error means you're not logged in

sushant
22 Dec, 2023, 10:23

okay thank you @Drake

Guille
22 Dec, 2023, 11:51

Can you share information about how you solve the first issue?

sushant
22 Dec, 2023, 14:53

It got solved by creating permissions for other related collection as well

Guille
22 Dec, 2023, 14:53

Thank you! I'll set this as solved

Guille
22 Dec, 2023, 14:54

[SOLVED] Getting General Unknown Error using databases.createDocument()

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