Skip to content
Back

An internal curl error has occurred within the executor

  • 0
  • Users
  • Flutter
Ipsoka
27 Mar, 2023, 21:17

After executing my function in dart, im getting

An internal curl error has occurred within the executor

All I added to the function is

final listUser = await users.list(); listUser.users.forEach(print);

I also added APPWRITE_FUNCTION_ENDPOINT and APPWRITE_FUNCTION_API_KEY to the function, the apikey has the users.read permission. Am I missing something?

TL;DR
The user encountered an internal curl error within the executor when running a Dart function. They realized they needed to initialize the client before calling `users.list()`. Another user suggested following the example from the documentation and assigning the client as a variable before making the API call. There is no specific solution provided for the internal curl error.
Ipsoka
27 Mar, 2023, 21:20

` Future<void> start(final req, final res) async { final client = Client();

// Uncomment the services you need, delete the ones you don't // final account = Account(client); // final avatars = Avatars(client); // final database = Databases(client); // final functions = Functions(client); // final health = Health(client); // final locale = Locale(client); // final storage = Storage(client); // final teams = Teams(client); final users = Users(client);

final listUser = await users.list();

listUser.users.forEach(print);

if (req.variables['APPWRITE_FUNCTION_ENDPOINT'] == null || req.variables['APPWRITE_FUNCTION_API_KEY'] == null) { print( "Environment variables are not set. Function cannot use Appwrite SDK."); } else { client .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT']) .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID']) .setKey(req.variables['APPWRITE_FUNCTION_API_KEY']) .setSelfSigned(status: true); }

res.json({ 'areDevelopersAwesome': true, }); } ` Full dart function

rafagazani
27 Mar, 2023, 21:35

First assignment as variable in your client then you can call final listUser = await users.list();

listUser.users.forEach(print);

rafagazani
27 Mar, 2023, 21:37

please follow example from documentation <:appwritepeepo:902865250427215882> : https://appwrite.io/docs/functions#writingYourOwnFunction

rafagazani
27 Mar, 2023, 21:38
Ipsoka
27 Mar, 2023, 21:53

what do you mean with assigne as variable

Drake
27 Mar, 2023, 22:48

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

Drake
27 Mar, 2023, 22:50

You're calling users.list() before actually setting the endpoint and api key so users.list() throws an error and fails with the error message you shared.

make sure to initialize client first.

In addition, try to make sure your code doesn't throw any exceptions and res.json() is called exactly once

Ipsoka
27 Mar, 2023, 23:01

Hey, thanks for the answer. Why exactly do I need to specify the endpoint, the projectid and the key in this case? Isnt the function run in the backend, shouldnt it already have acceess to those things automatically? Or is it because it run in its separete container

Ipsoka
27 Mar, 2023, 23:02

Maybe I'm missing something here. Also, is it safe to just hard code the api key into my cloud function?

Ipsoka
27 Mar, 2023, 23:03

Or should these values be set as envs for the function?

Ipsoka
27 Mar, 2023, 23:07

nvm, I can answer my question my self, I just gotta read the else in code, which litrally takes the data out of the env and initilizes the client. Now I see, thanks 😄

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