
I have this barebones POST endpoint on Next JS.:
export async function POST(req:Request){
try {
const conversation = await req.json() as INewConversation;
const {database,config} = await createSessionClient();
const conv = await database.createDocument(config.databaseId,
config.conversationCollectionId,
ID.unique(),
conversation
);
return NextResponse.json(conv as unknown as IConversation);
}catch (error) {
return new NextResponse(`Internal Error - ${error}`, { status: 500 }) }
}
Now, the conversation table has the attributes in attached image. It has relationships to the user and messages tables.
Permissions I made sure to tick them all for "Any role" for the main table and the relationship tabled.
How come I am still getting the below error on document creation:
"AppwriteException: The current user is not authorized to perform the requested action."
This seems like a very stupid mistake from my end but I have other tables which are working fine and this one just won't work. I am able to create entries from the GUI as an admin.
Appwrite docker log:
2024-05-28T17:36:56.829015933Z [Error] Timestamp: 2024-05-28T17:36:56+00:00
2024-05-28T17:36:56.829061804Z [Error] Method: POST
2024-05-28T17:36:56.829069100Z [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents
2024-05-28T17:36:56.829073822Z [Error] Type: Appwrite\Extend\Exception
2024-05-28T17:36:56.829079045Z [Error] Message: The current user is not authorized to perform the requested action.
2024-05-28T17:36:56.829083896Z [Error] File: /usr/src/code/app/controllers/api/databases.php
2024-05-28T17:36:56.829088082Z [Error] Line: 2839
Recommended threads
- JSON and Object Support in Collection do...
I am working with Next.Js and Appwrite Cloud, I am relatively New to Appwrite but i have noticed there is no direct support of JSON and Object support in attrib...
- list() is very slow; eventually shows no...
When I use the web browser to view the collections in my database, the documents they contain are normally displayed within a few seconds. For a few days now, h...
- Can't start docker containers beacuse no...
Hi, I'm testing my app where I upload also files to appwrite storage. As I suspect, I've filled up my disk. Now I can't start Appwrite. Could I ask for help wit...
