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
- TablesDB `updateRows` returns `database_...
Hi Appwrite team! I’m seeing a strange issue with TablesDB bulk row updates on a self-hosted Appwrite instance. **Environment** - Appwrite self-hosted `1.9.0` ...
- Update row sheet not loading
After right clicking a row header and click update, the sidebar fails to load (never-ending skeleton)
- DB Relational Table Request
Hi, I'd like to suggest a rewording of the relationships between tables. - Current wording: storeOperatingDays can contain one storeId ...