Back

500 Server Error Creating Related Documents

  • 0
  • Databases
  • Flutter
hamed
7 May, 2023, 01:10

It works fine on the console, but the opposite happens with the client SDK. Here are my code snippets (Note that it does work if I remove the relationship) :

TypeScript
await ApiConst.databases.createDocument(
                          databaseId: ApiConst.databaseID,
                          collectionId: ApiConst.postsCollectionID,
                          documentId: ID.unique(),
                          data: {
                            'title': 'Lorem ipsum',
                            'body':
                                'Lorem ipsum is placeholder text commonly used in the graphic...',
                            'comments': '6456f4e874e9f5bbd504' // Relationship
                          },
                        );

Here the error :

TypeScript
AppwriteException (AppwriteException: general_unknown, Server Error (500))
TL;DR
User is experiencing a 500 server error when creating related documents in a 'one-way relationship' from the client SDK. They mention that adding the relationship ID in square brackets resolves the issue. Another user suggests that the error should be more descriptive instead of a general_unknown error. The user also provides code snippets and the error message they are receiving. No solution is mentioned in the thread.
Drake
7 May, 2023, 04:17

What kind of relationship is the comments attribute?

Also, would you please look at the docker logs for the appwrite container and share the logs for the related 500 error

steve jobs
7 May, 2023, 05:13

i have also noticed lot of known simple errors are shown as [general_unknown, Server Error (500)] . and i had to use appwrite log to debug the code. it would be great if that correct error is shown as specific error in the server response instead of general_unknown error.

Drake
7 May, 2023, 05:46

We really shouldn't be showing 500. It might be good to create an issue for whichever 500 error you're seeing so we can update it to be more descriptive

steve jobs
7 May, 2023, 05:54

in this channel or in git?

hamed
7 May, 2023, 09:33

Its is " One to many "

hamed
7 May, 2023, 10:21

That`s strange, it worked after adding the relationship ID into square brackets.

TypeScript
'comments': ['6456f4e874e9f5bbd504'] // Relationship

I`m confused because in another project, it worked fine without these square brackets.

Vedsaga
7 May, 2023, 10:44

it is because if you have attribute with relationship enable then it is required

steve jobs
7 May, 2023, 10:47

its one to many relationship, so you have to give an array of documents.. if it was one to one or many to one , then you can give a single item . i guess

hamed
7 May, 2023, 11:06

Uh, I see. Thanks. By the way, have you ever encountered this issue when adding items to a 'one-way relationship' from the client SDK? It seems to override previous items.

Drake
7 May, 2023, 14:25

GitHub

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more