Back

Execute function not working

  • 0
  • Functions
mitsy0_0
5 Jun, 2023, 19:35

error: AppwriteException: Invalid data: Value must be a valid string and no longer than 8192 chars

code: const promise2 = functions.createExecution("647c55d49f0f42exxxxx", {"name": names, "about": details});

TL;DR
The user is having trouble with an execute function in their code. They are using `json.loads()` to handle `req.payload`. They want to know how to pass multiple inputs and if they can pass inputs that aren't in JSON format. However, they are receiving an error that says the input must be a string. The code works fine when executed from the appwrite console. The error message suggests that the input must be a valid string and no longer than 8192 characters. The solution may be to check the format of the input being passed and ensure it is a valid string within the specified length limit.
mitsy0_0
5 Jun, 2023, 19:36

names is a list of names, but it works fine when I execute the function from appwrite console with same input

Drake
5 Jun, 2023, 19:54

Read the error and look at your input

mitsy0_0
5 Jun, 2023, 19:56

it says the input can only be string

mitsy0_0
5 Jun, 2023, 19:56

not even JSON?

mitsy0_0
5 Jun, 2023, 19:56

But then how do I pass multiple inputs

Drake
5 Jun, 2023, 19:57

how are you handling req.payload in your function code?

mitsy0_0
5 Jun, 2023, 19:57

user_names = json.loads(req.payload)["name"]

Drake
5 Jun, 2023, 19:58

so think about that...json.loads()...

mitsy0_0
5 Jun, 2023, 19:58

um ok

mitsy0_0
5 Jun, 2023, 19:59

Oh

mitsy0_0
5 Jun, 2023, 20:00

I think I got it

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