[SOLVED] Problems with adding a new document in appwrite via function
- 0
- Self Hosted
- Functions
- Databases
- Cloud

Maybe i should not create an array EventData with all these elements because it is more complicated

This is not the problem That is just fine

Did you try to send the data without eventId
?

yes it failed with no response showing

Mmm
We can try one more thing
Can you share the payload
data?

async : true data : "{\n eventData: {\n eventId: ID::unique(),\n title: New Event,\n description: Event description,\n owner: 648051d777d7ac754e75,\n image: 64b4fec93805d8f21470,\n location: Event location,\n date: 18/07/2023 11:57:45.251,\n endDate: 19/07/2023 11:58:17.701,\n innocaps: [tag1, tag2, tag3]\n }\n


You send the ID::unique()
it won't work with it
Can you replace the whole string with this and try
{
"eventData": {
"eventId": "unique()",
"title": "New Event",
"description": "Event description",
"owner": "648051d777d7ac754e75",
"image": "64b4fec93805d8f21470",
"location": "Event location",
"date": "18/07/2023 11:57:45.251",
"endDate": "19/07/2023 11:58:17.701",
"innocaps": ["tag1", "tag2", "tag3"]
}
}

{"data":"{\n eventData: {\n eventId: unique(),\n title: New Event,\n description: Event description,\n owner: 648051d777d7ac754e75,\n image: 64b4fec93805d8f21470,\n location: Event location,\n date: 18/07/2023 11:57:45.251,\n endDate: 19/07/2023 11:58:17.701,\n innocaps: [tag1, tag2, tag3]\n }\n}","async":true}


Good And you got on this one?

the execution with the payload that you sent was failed

please share the error and updated code. Please also share the list of attributes for your events collection

Response: {"success":false,"message":"Invalid payload. eventData is missing."} Logs: NULL


can you add var_dump($req['payload'])
before the json_decode()
.
Do you see anything in the errors tab?

Response: {"success":false,"message":"Invalid payload. eventData is missing."} Logs: string(360) "{ "eventData": { "eventId": ID::unique(), "title": "Sample Event", "description": "This is a sample event description.", "owner": "648051d777d7ac754e75", "image": "64b4fec93805d8f21470", "location": "Sample Location", "date": "20/07/2023 11:57:45.251", "endDate": "21/07/2023 11:57:45.251", "innocaps": ["innocap"] } } "

No, there are no errors recorded

You should not be putting ID::unique()
in there. that was already mentioned to you

No, this doesn't solve the problem for me

what's the new output and code?

Response: 'Invalid payload. eventData is missing. Logs: string(341) "{ "eventId": "ID::unique()", "title": "Sample Event", "description": "This is a sample event description.", "owner": "648051d777d7ac754e75", "image": "64b4fec93805d8f21470", "location": "Sample Location", "date": "24/07/2023 11:57:45.251", "endDate": "25/07/2023 11:57:45.251", "innocaps": ["innocap"] } "

so that's your $req['payload']
...do you see eventData
in there?

I solved it by deleting eventData and only using payload. It works now

[SOLVED] Problems with adding a new document in appwrite via function
Recommended threads
- Upgrading Appwrite 1.7.4 → 1.8.x: What H...
I'm currently running a self-hosted Appwrite v1.7.4 instance that still uses the old Collections/Documents database model. I noticed that starting from v1.8.x,...
- Domain not working
My domain [fork-fable.appwrite.network](https://fork-fable.appwrite.network/) returns a 500 even after deleting and redeploying. Other domains added in domains ...
- File tokens regenerate each page reload
Hello, on appwrite 1.7.4, when I create a file token via the API Tokens(appwriteAdminClient)#createFileToken I get a secret, then when I check in the console t...
