[SOLVED] Creating collection with Server SDK and reading from it on Client SDK
- 0
- Flutter
- Functions
- Cloud

I am creating collection by function execution and then check if execution was successful then get its documents but hence leads to unauthorized_scope error. Remember users permissions are provided in server side function execution. After HotReload everything works fine and same user can get all documents from newly created Collection.

I think after successful execution of functions which creates Collection, it's attributes, indices and set Permissions, "completed" status is returned while permissions are not created yet. @Moderator

Seems like the user doesnt has permission for a document?

If you have appwrite 1.3.x upgrade to the last version 1.3.4, since previous had a problem with permissions migration

@Hassanmrwt could you share the code for this function?

Sure

Full code in file

Function works fine, completes it's execution but accessing newly created Collection's documents throws permissions error

okay here's what i can think of

in your function code, you're not await-ing every call to create attributes, etc.

which is causing the code to jump through without even checking if the execution of each call was complete. And hence you get the status: ok

what i would do is

Find a way to cheat my code Closed the code in try {
from where error is thrown
db.listDocuments() }on AppwriteException { called the same above code again and works fine }
🙈🙈

await each of these calls amd try again. might slow it down a little, but might work!


Yes this could be the exact error let me go through this again and see what's happen

not exactly a good practice for production 😅

Yes

let me know! if i stop replying, I've fallen asleep 😅 it's way past my bed time lmaoooo

Have nice dreams 💤

Yes 👍 did work 👍

Just awaited on creating attributes and index

Sounds good!

[SOLVED] Creating collection with Server SDK and reading from it on Client SDK
Recommended threads
- Is my approach for deleting registered u...
A few weeks ago, I was advised not to use the registered users' id in my web app. Instead, I store the publicly viewable information such as username and email ...
- ❗[Help] Function stuck in "waiting" stat...
Hi Appwrite team 👋 I'm trying to contribute to Appwrite and followed the official setup instructions from the CONTRIBUTING.md guide to run the platform locall...
- Unable to create push providers - FCM or...
Currently unable to create a push provider for FCM or APNS.... https://github.com/appwrite/console/issues/2045 When uploading a file... FCM = Valid file retu...
