Back

Permission error

  • 0
  • Databases
  • Flutter
Dahriim
9 Mar, 2024, 10:46

Hi, I'm trying to get at least a simple confirmation message that the query is working, but it seems that something is off with permissions, even thought I've set the collection permissions to Any in my Appwrite database collection console. The error I get is : "AppwriteException: user_unauthorized, The current user is not authorized to perform the requested action. (401)"

If the query returns nothing, it correctly prints "Match not found", but if it does, it just throws that exception. What am I doing wrong?

Thank you

final TextEditingController _searchController = TextEditingController(); final databases = Databases(Appwrite.instance.client); List<Document> searchResults = []; String searchMessage = '';

Future<void> searchCareer(String query) async { try { final documents = await databases.listDocuments( databaseId: constants.appwriteDatabaseId, collectionId: constants.appwriteCollectionId, queries: [ Query.equal("career_name", query) ], );

TypeScript
  setState(() {
    searchResults = documents.documents;
    searchMessage = searchResults.isNotEmpty ? 'Found match' : 'Match not found';
  });


} on AppwriteException catch (e) {
  print(e);
}

}

TL;DR
Developers are experiencing a permission error when trying to execute a query in their Appwrite database collection. The error message "user_unauthorized" appears even though they have set collection permissions to Any. The query correctly prints "Match not found" if no results are returned, but throws the exception if there is a match. The issue may be related to user authorization.
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