Back

[SOLVED] Document Creation

  • 0
  • Web
Drake
2 May, 2023, 00:40

👀

TL;DR
The user was initially confused about how to pass arguments to the `createDocument()` function. They eventually figured out that they needed to put the arguments into an array. However, they encountered an error stating that the value must be a valid JSON string. The solution provided was to remove the curly brackets (`{}`) from each argument and use just the variable name. The corrected code was provided as an example.
Drake
2 May, 2023, 00:41

Do you know what this does?

TypeScript
databases.createDocument('64502243369b884d71f8', '6450225bbca140600f16', ID.unique(), {name},  {DOB}, {feet}, {inch}, {weight}, {school}, {sport}, {position}, {age}, {better})
Drake
2 May, 2023, 00:41

e.g. what this is? {name}

BloodThermic
2 May, 2023, 00:41

yes I do

BloodThermic
2 May, 2023, 00:41

They are all form inputs

BloodThermic
2 May, 2023, 00:41

I have also tried without the brackets and samething

Drake
2 May, 2023, 00:42

you know that {name} is the same as {name: name}?

BloodThermic
2 May, 2023, 00:43

What do you mean Im confused

Drake
2 May, 2023, 00:43

{name} is syntactic sugar for {name: name}

BloodThermic
2 May, 2023, 00:43

This is the output I get when I do no brackets AppwriteException [Error]: Invalid data: Value must be a valid JSON string at Client.call (C:\Users\canno\Desktop\Work\Clients\Phelps-Fitness\phelps-fit-2\node_modules\node-appwrite\lib\client.js:172:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Databases.createDocument (C:\Users\canno\Desktop\Work\Clients\Phelps-Fitness\phelps-fit-2\node_modules\node-appwrite\lib\services\databases.js:1666:16) { code: 400, type: 'general_argument_invalid', response: { message: 'Invalid data: Value must be a valid JSON string', code: 400, type: 'general_argument_invalid', version: '1.2.0' } }

Drake
2 May, 2023, 00:44
Drake
2 May, 2023, 00:44

how many arguments does createDocument() expect?

BloodThermic
2 May, 2023, 00:45

10

Drake
2 May, 2023, 00:45

no

BloodThermic
2 May, 2023, 00:45

Oh your asking for appwrite

BloodThermic
2 May, 2023, 00:45

Well I am guessing only 1 by how this is working out for me

Drake
2 May, 2023, 00:46

no

BloodThermic
2 May, 2023, 00:47

Ok I am understanding now I think. I just figured out how to do what you just did. so 5 arguments

BloodThermic
2 May, 2023, 00:48

So I need to put it into an array then use it?

Drake
2 May, 2023, 00:48

no

Drake
2 May, 2023, 00:49
BloodThermic
2 May, 2023, 00:51

Got it!!!

BloodThermic
2 May, 2023, 00:51
TypeScript
            Name: name,
            DOB: DOB,
            Feet: feet,
            Inch: inch,
            Weight: weight,
            School: school,
            Sport: sport,
            Position: position,
            Age: age,
            Better: better
        };```
BloodThermic
2 May, 2023, 00:52

Thank you!!

Drake
2 May, 2023, 00:54

[SOLVED] Document Creation

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