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
- The console isnt showing documents
In console ui saved documents are being shown on frontend but i can see its showing 4 or number of docs available but in rows its only showing single doc and th...
- 1.8.1 - Databases - inline updating a ro...
When updating a database field via the inline edit method, the `$updatedAt` column does not get updated. Only if the row is updated by the "Update" interface (t...
- Other DateTime Columns Are Saved Incorre...
When opening a row’s details from the console and editing any field, the timestamps of other DateTime columns are being automatically changed and incorrectly sa...