Back

Patch Request, return 401 if some document have been linked

  • 0
  • Databases
Vedsaga
18 May, 2023, 07:36

So, I have two collection

TypeScript
Beat <-> Client

case 1:- When there is no Clients Document linked to Beat meaning, if we check how many document linked to beat then it will result in 0. And, Then when you try to send update req it success and we get 200. req body :- json {"data":{"beatName":"Test","beatNumber":5,"beatDay":"thursday","startLocation":"Test","endLocation":"Test"}} reponse body json {"beatName":"Test","beatNumber":5,"endLocation":"Test","startLocation":"Test","beatDay":"thursday","$id":"64651e78e52661b666a1","$createdAt":"2023-05-17T18:35:36.939+00:00","$updatedAt":"2023-05-18T07:21:37.937+00:00","$permissions":[],"clientLink":[],"$databaseId":"6451d90b58e5630094e5","$collectionId":"645c9e293be3c3ee04e1"}

case 2:- When there is 1 or more Clients Document linked to Beat meaning, if we check how many document linked to beat then it will result in >0. And, Then when you try to send update req it success and we get 401, req body

TypeScript
{"data":{"beatName":"Test","beatNumber":5,"beatDay":"sunday","startLocation":"Test","endLocation":"Test"}}

resp body

TypeScript
{"message":"The current user is not authorized to perform the requested action.","code":401,"type":"user_unauthorized","version":"1.3.4"}

Things that that doubled checked,

  1. granted update permission to both document to all registered users.
TL;DR
The user is requesting a patch update that will return a 401 status code if a document has been linked. There are two cases: 1. If no documents are linked to the beat, updating the beat with a specific collection is successful and returns a 200 status code. 2. If one or more documents are linked to the beat, updating the beat with the specific collection will result in a 401 status code, indicating that the current user is not authorized to perform the action. The user has already granted update permissions to both documents for all registered users.
Vedsaga
18 May, 2023, 07:40

Additional Note:- Relationship type is 2 ways, and One to Many from beat to client.

Vedsaga
18 May, 2023, 07:45

Patch Request, return 401 if some document have been linked

Drake
18 May, 2023, 17:47

What are the permissions on client collection?

Vedsaga
18 May, 2023, 17:47

Any user can update/create/read

Vedsaga
18 May, 2023, 17:48
Drake
18 May, 2023, 17:49

Does the client collection have any relationship attributes?

Vedsaga
18 May, 2023, 17:49

yap with πŸ‘€

Drake
18 May, 2023, 17:51

So what are the collection permissions on those?

Vedsaga
18 May, 2023, 17:51

😬

Vedsaga
18 May, 2023, 17:51

phone

Vedsaga
18 May, 2023, 17:51

address

Drake
18 May, 2023, 17:52

Ya missing update. That's probably why

Vedsaga
18 May, 2023, 17:52

umm, does why is that I wonder, I mean I don't think it's ideal right?

Vedsaga
18 May, 2023, 17:53

because want to only need to update the specific collection only and not all sub-related collection

Drake
18 May, 2023, 17:58

Yes, this is the related issue: https://github.com/appwrite/appwrite/issues/5404

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