Back

[error] getting error if trying to print payload

  • 0
  • Android
  • Flutter
  • Self Hosted
  • Functions
conqueror
6 May, 2023, 05:08

if trying to print payload then its giving error else its working fine, An internal curl error has occurred within the executor! Error Msg: Operation timed out

TL;DR
The user is getting an error when trying to print the payload. They are using single quotes instead of double quotes in the JSON string, which is causing the error. They need to use `jsonDecode()` to convert the JSON string to a map. If the execution is delayed, they may also get a timeout error.
Drake
6 May, 2023, 05:16

Please share your code

conqueror
7 May, 2023, 00:17

why payload is not printing ,

TypeScript
//assigning 
final payload = !req.payload?.isEmpty ? req.payload : 'No payload provided. Add custom data when executing function.';  
//printing 
print(payload["hallelujah"]);

and here is custom data or providing payload to appwrite console```{ 'hallelujah':[ { 'image': 'image', 'productName': 'love you jesus ', 'productUnit': 'productUnit', 'barcode': 55558888, 'id': " d5454a", 'sellingPrice': 44.0, 'totalQuantity': 100.0, 'quantity': 1.0 } ]

}```

Drake
7 May, 2023, 00:19

What doesn't this work?

TypeScript
final payload = "I'm a string";
print(payload["key"]);
conqueror
7 May, 2023, 00:20

yes, this does not work some time , its saying "type '_OneByteString' is not a subtype of type 'int' of 'index'" and if execution is delaying then it just says An internal curl error has occurred within the executor! Error Msg: Operation timed out

Drake
7 May, 2023, 00:22

You'll see that operation timed out if your function throws an exception

Drake
7 May, 2023, 00:23

You need to send a valid JSON string for the data. Single quotes are not valid in JSON.

Then, you need to use jsonDecode() to convert the JSON string to a map

conqueror
7 May, 2023, 00:41

now its working , thanks @Steven

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