Back

Cant create document

  • 0
  • Self Hosted
  • React Native
Jeratomb
19 Oct, 2024, 22:17

Hello! I want to create a document but get this error

[AppwriteException: Permissions must be one of: (any, users, user:66f3de0000033ba635fe, user:66f3de0000033ba635fe/verified, users/verified, label:admin)]

This is the function where the error is catched

export const createNewWorkoutplan = async (name, duration, workouts, days,user) => { try { const newWorkoutplan = await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.workoutplanCollectionId, ID.unique(), { Name: name || 'New Workoutplan', Duration: duration, Workouts: workouts, Days: days, CreatedAt: new Date().toISOString(), }, [ Permission.read(Role.user(user.$id),"verified"), Permission.write(Role.user(user.$id),"verified") ] );

TypeScript
  return newWorkoutplan;
} catch (error) {
  console.error('Error creating workout plan:', error);
  throw error;
}

};

in the database my user has all permissions aswell as all users have all rights for the collection

Would be great if anyone can help out!

TL;DR
Developers are having trouble creating a document due to permissions error. The error message requires permissions to be one of: (any, users, user:specific_user_id, user:specific_user_id/verified, users/verified, label:admin). The solution involves ensuring the permissions are correctly set in the createNewWorkoutplan function.
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