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
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.