Failing to execute functions: Error Msg:{"error":"type 'Null' is not a subtype of type 'String'"}
- 0
- Flutter
- Functions
yes
Okay it should be the same then
for checking how can i print payload in console or log
Use print() but make sure to pass it a string
here is raw data ```{ "$id": "6452d0f3ce9edca1866d", "$createdAt": "2023-05-05T23:56:37.807+00:00", "$updatedAt": "2023-05-06T00:37:35.262+00:00", "execute": [
], "name": "func", "enabled": true, "runtime": "dart-2.17", "deployment": "6455a13c9026fb596952", "vars": [
], "events": [
], "schedule": "", "scheduleNext": "", "schedulePrevious": "", "timeout": 15 }```
payload is not printing in response nor in console, print( response.json(payload.toString()));
print(payload.toString());
Why are you calling response.json() like that?
Also your error could be happening before the print
not using that
Sorry, what?
just mistakenly copied, trying to see whether it prints on response section or not( or happening something in console).
here is the trace {"error":"type 'Null' is not a subtype of type 'String'#0 start (package:appwrite_function\/main.dart:10)\n#1 main.<anonymous closure>.<anonymous closure> (file:\/\/\/usr\/local\/src\/server.dart:37)\n#2 main.<anonymous closure>.<anonymous closure> (file:\/\/\/usr\/local\/src\/server.dart:36)\n#3 _rootRun (dart:async\/zone.dart:1426)\n#4 _CustomZone.run (dart:async\/zone.dart:1328)\n#5 _runZoned (dart:async\/zone.dart:1861)\n#6 runZonedGuarded (dart:async\/zone.dart:1849)\n#7 main.<anonymous closure> (file:\/\/\/usr\/local\/src\/server.dart:35)\n<asynchronous suspension>\n#8 handleRequest (package:shelf\/shelf_io.dart:138)\n<asynchronous suspension>\n"}
And your file is named main.dart? If so, the problem is around line 10
yes
here is file structure
also change function name (at line 10) main to mainfunc but still giving the same error
Wait line 10 was the function name?
It should be start...
yes its function name define inside ServerAppwrite class
do you mean i have to define main then call this start inside main, right ?
why its printing Environment variables are not set. Function cannot use Appwrite SDK. executing this function in appwirte console ```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);
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, }); }```
Did you create the variable?
after creating the variable its working fine,
trying to print payload but if i add print statement then function execution is failed saying An internal curl error has occurred within the executor! Error Msg:
Operation timed out other wise its working fine, this is how using print
print(req.payloads.toString());
req doesn't have payloads. It's payload
Recommended threads
- Compatibility issue with Kakao OpenID Co...
**Context:** I am attempting to integrate **Kakao Login** (one of the largest social login providers in South Korea) into my Flutter application using Appwrite'...
- [SOLVED] Appwrite 25.1.0 returns Invalid...
I've already opened an issue on GitHub, but somewhat it doesn't seem like GitHub is monitored very closely, so I'm leaving a bug report here on Discord as well....
- [v1.8.1] Getting error "(role: applicati...
... but that scope doesn't exist. I am trying to get a function to run and modify tables in the database dynamically. I set everything up and eventually got: ...