Back

500 server error on creating document with relationships

  • 1
  • Databases
Dipen
22 Jul, 2023, 05:58

I'm getting 500 error on creating document with relationship

TL;DR
User is experiencing a 500 server error when trying to create a document with relationships. They have create access on the carts table, but not on the products table. The user is wondering if they need to add create access on the products table as well. It is suggested that the user needs access to every related document. The user updates the permission but it seems that they still do not have update access to the related document. The user shares their code and asks for the docker logs for the appwrite container. Solution: Ensure the user has update access to the related document and check the docker logs for the appwrite container for more information on
Drake
22 Jul, 2023, 06:00

What do the docker logs for the appwrite container say for the 500 error?

Also, what's your code?

Dipen
22 Jul, 2023, 06:01
TypeScript
await database.createDocument(
  databaseId: [DB ID],
  collectionId: [Collection ID],
  documentId: ID.unique(),
  data: {
    "user_id": userId,
    "product_id": [productId],
    "quantity": 1,
  },
);
Dipen
22 Jul, 2023, 06:01

code

Dipen
22 Jul, 2023, 06:05

docker log

Dipen
22 Jul, 2023, 06:05
Drake
22 Jul, 2023, 06:16

It's a little hard to read because its cut off but it looks like a permission problem. Does the user have update access to the related document?

D5
22 Jul, 2023, 15:16

Looks like it doesn't has update permission

Dipen
22 Jul, 2023, 16:24

i have updated the permission

Dipen
22 Jul, 2023, 16:24

but it showed this

Drake
22 Jul, 2023, 17:33

What are the permissions on product and does product have any other related documents?

Dipen
24 Jul, 2023, 04:17

i haven't added permission on the products to create for this user but only for carts

Drake
24 Jul, 2023, 04:19

The user needs access to every related document

Dipen
24 Jul, 2023, 04:19

to create carts, i'll need to add create access on my products table as well?

Drake
24 Jul, 2023, 04:20

If the user is creating a document in that collection, then yes

Dipen
24 Jul, 2023, 04:21

I'm creating document on carts table not on products

Dipen
24 Jul, 2023, 04:22

and i have create access on carts

Drake
24 Jul, 2023, 04:26

Ok so?

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