Don't think so
[Solved] user_unauthorized in appwrite function using Server Dart SDK and API KEY
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
same problem with jwt - user is not authorized, even when all collections have all permissions available to "any"
Rank 3: Container
Rank 3: Container
Rank 3: Container
removed all other fields from collection, only relation is present
Rank 3: Container
tested other relations and only with twoWay relations there is such problem
so i just tested and i was able to create fine with an api key:
$ appwrite --json databases createDocument --databaseId "many-to-one" --collectionId "level1" --documentId "level1" --data '{ "level2": { "$id": "level2", "level3": { "$id": "level3", "level4": { "$id": "level4", "level5": { "$id": "level5" } } } }}'{ "$id": "level1", "$permissions": [], "$createdAt": "2023-07-20T21:50:55.904+00:00", "$updatedAt": "2023-07-20T21:50:55.904+00:00", "level2": { "$id": "level2", "$createdAt": "2023-07-20T21:50:55.905+00:00", "$updatedAt": "2023-07-20T21:50:55.905+00:00", "$permissions": [], "level3": { "$id": "level3", "$createdAt": "2023-07-20T21:50:55.906+00:00", "$updatedAt": "2023-07-20T21:50:55.906+00:00", "$permissions": [], "$databaseId": "many-to-one", "$collectionId": "level3" }, "$databaseId": "many-to-one", "$collectionId": "level2" }, "$databaseId": "many-to-one", "$collectionId": "level1"}✓ Successhere are my collections:
Let me remove permissions:
and it still works:
$ appwrite --json databases createDocument --databaseId "many-to-one" --collectionId "level1" --documentId "level1" --data '{ "level2": { "$id": "level2", "level3": { "$id": "level3", "level4": { "$id": "level4", "level5": { "$id": "level5" } } } }}'{ "$id": "level1", "$permissions": [], "$createdAt": "2023-07-20T21:54:59.591+00:00", "$updatedAt": "2023-07-20T21:54:59.591+00:00", "level2": { "$id": "level2", "$createdAt": "2023-07-20T21:54:59.592+00:00", "$updatedAt": "2023-07-20T21:54:59.592+00:00", "$permissions": [], "level3": { "$id": "level3", "$createdAt": "2023-07-20T21:54:59.593+00:00", "$updatedAt": "2023-07-20T21:54:59.593+00:00", "$permissions": [], "$databaseId": "many-to-one", "$collectionId": "level3" }, "$databaseId": "many-to-one", "$collectionId": "level2" }, "$databaseId": "many-to-one", "$collectionId": "level1"}✓ SuccessRank 3: Container
Thanks a lot!
Im comparing it to mine and in the meantime I will paste mine:
Rank 3: Container
and insert try:
appwrite --json databases createDocument --databaseId "main_database" --collectionId "content_entry" --documentId "test1" --data '{"name":"test","assignedToCategories":[{"$id":"64b9b41199345ad2a55d"}]}'
✗ Error The current user is not authorized to perform the requested action.
Rank 3: Container
64b9b41199345ad2a55d is already existing object of type category
Rank 3: Container
@Steven maybe problem is that im trying to insert document with relation from the "child" side?
Rank 3: Container
ok, so its possible to create child or parent of the relation but cant reference it
Rank 3: Container
also now getting 500
appwrite --json databases updateDocument --databaseId "main_database" --collectionId "category" --documentId "k1" --data '{"content": ["c1"]}' --verbose
AppwriteException [Error]: Server Error
at Client.call (/opt/homebrew/Cellar/appwrite/HEAD-b461997/libexec/lib/node_modules/appwrite-cli/lib/client.js:209:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async databasesUpdateDocument (/opt/homebrew/Cellar/appwrite/HEAD-b461997/libexec/lib/node_modules/appwrite-cli/lib/commands/databases.js:1353:16) {
code: 500,
response: [Object: null prototype] {
message: 'Server Error',
code: 500,
type: 'general_unknown',
version: '1.3.7',
file: '/usr/src/code/vendor/utopia-php/database/src/Database/Database.php',
line: 3090,
trace: [
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype],
[Object: null prototype]
]
}
}
✗ Error Server Error
Rank 3: Container
works from the "child" side
Rank 3: Container
appwrite --json databases updateDocument --databaseId "main_database" --collectionId "content_entry" --documentId "c1" --data '{"assignedToCategories": ["k1"]}' --verbose
{
"name": "c1",
"$id": "c1",
"$createdAt": "2023-07-20T22:59:38.347+00:00",
"$updatedAt": "2023-07-20T23:03:52.676+00:00",
"$permissions": [],
"assignedToCategories": [
{
"name": "k1",
"$id": "k1",
"$createdAt": "2023-07-20T22:59:46.246+00:00",
"$updatedAt": "2023-07-20T23:03:52.679+00:00",
"$permissions": [],
"$databaseId": "main_database",
"$collectionId": "category"
}
],
"$databaseId": "main_database",
"$collectionId": "content_entry"
}
✓ Success
Rank 3: Container
no error while creating, but no relation either:
appwrite --json databases createDocument --databaseId "main_database" --collectionId "category" --documentId "k2" --data '{"name":"k2", "content": ["c1"]}' --verbose
{
"name": "k2",
"$id": "k2",
"$permissions": [
"read(\"user:64b43b2993b48df0d16b\")",
"update(\"user:64b43b2993b48df0d16b\")",
"delete(\"user:64b43b2993b48df0d16b\")"
],
"$createdAt": "2023-07-20T23:05:14.443+00:00",
"$updatedAt": "2023-07-20T23:05:14.443+00:00",
"$databaseId": "main_database",
"$collectionId": "category"
}
✓ Success
are you trying to create those nested assignedCategories or link?
Rank 3: Container
link
to link, you should put an array of ids rather than passing an array of objects
Rank 3: Container
Yes! That was it! I was passing array of json objects with id instead of string array of ids
Rank 3: Container
Thank you Steven, you saved the day again
Rank 3: Container
[Solved] user_unauthorized in appwrite function using Server Dart SDK and API KEY