I am lost and have no idea how to fix this
I am trying to update a document with the server SDK in my NextJS applications
this is our // src/app/api/matches/updateMatch/route.ts
try { const { databases, account } = await createSessionClient( sessionCookie.value ); await databases.updateDocument( process.env.NEXT_PUBLIC_DATABASE_ID!, process.env.NEXT_PUBLIC_COLLECTION_MATCHES!, matchId, { [key]: value } );
this is the request
const response = await fetch(`/api/matches/setup`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ key, value: validatedValue, matchId }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
this is the error Compiled /api/matches/setup in 614ms (849 modules) Session Cookie: eyJpZCI6IjY3MGFkOT... Updating document with: { databaseId: '66------------d0', collectionId: 'matches', matchId: '6745ba27001606a4215b', data: { location: '6712a842000b8bc14916' } } API Error: AppwriteException: Server Error at async PATCH (src\app\api\matches\setup\route.ts:43:4)
41 | }); 42 |
43 | await databases.updateDocument( | ^ 44 | process.env.NEXT_PUBLIC_DATABASE_ID!, // databaseId 45 | process.env.NEXT_PUBLIC_COLLECTION_MATCHES!, // collectionId 46 | matchId, // documentId { code: 500, type: 'general_unknown', response: [Object] } PATCH /api/matches/setup 500 in 1981ms
all of the env variables are correct.
I am lost and don't know what to do next in trouble shooting.
any help would be appreciated
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
Before throwing that http error, can you try logging the response body?
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...