Back

[SOLVED] Not able to create document with function

  • 0
  • Self Hosted
  • Functions
  • Databases
D5
23 May, 2023, 08:17

So you basically need to put payload between {}

TL;DR
Issue: Not able to create document with function Solution: The problem was that the `APPWRITE_FUNCTION_ENDPOINT` variable was not set correctly. After configuring the API key and endpoint, the issue was resolved. Additionally, when running `npm run build` before uploading the build, it was found to be tedious. However, it was discovered that the build step could be skipped. Permissions should also be checked in the collection to ensure the ability to insert the document. Finally, all required data should be properly filled in the payload for the document creation to be successful.
D5
23 May, 2023, 08:21

Also make sure it fills all required data, since if it's not filled, a document will not be created

Nimit Savant
23 May, 2023, 08:54

Done

Nimit Savant
23 May, 2023, 08:54

It's not working

SnoefDoef
23 May, 2023, 09:56

Do you have set permissions in the collection?

SnoefDoef
23 May, 2023, 09:57

e.g. go to the collection you want to insert the document in and give 'Any' permission to read and insert and then see if you are able to create the document

D5
23 May, 2023, 10:07

If having token, that's not required

Drake
23 May, 2023, 15:20

what's the error? also, instead of console.log(error), would you please change it to console.log(error.toString())?

Nimit Savant
23 May, 2023, 15:57

There is none it's just going to show that response and there is no doc made.

Drake
23 May, 2023, 15:58

Did you try again after switching to err.toString()

Nimit Savant
23 May, 2023, 18:49

this

Drake
23 May, 2023, 18:52

nice. did you use localhost as your endpoint?

Nimit Savant
23 May, 2023, 18:55

hopefully no

Nimit Savant
23 May, 2023, 18:56
Drake
23 May, 2023, 18:56

would you please check the APPWRITE_FUNCTION_ENDPOINT variable?

Nimit Savant
23 May, 2023, 18:56

sure

Nimit Savant
23 May, 2023, 19:03

this code is working locally when I run directly this module on a server, but on appwrite function its not running :(

Nimit Savant
23 May, 2023, 19:08

yup that was the error

Nimit Savant
23 May, 2023, 19:09

but shouldn't APPWRITE_FUNCTION_ENDPOINT already have the endpoint details?

Nimit Savant
23 May, 2023, 19:14

Steven any idea how to skip the build step for ts npm run build before uploading the build. Like its too tedious to first build and then ship.

Nimit Savant
23 May, 2023, 19:15

It working now!

Drake
23 May, 2023, 19:32

We're addressing this in the near future

shaquer
25 May, 2023, 11:14

I still have the problem with APPWRITE_FUNCTION_ENDPOINT. I tried localhost (should not work in docker environment) and the ip of my local computer. i still get Error: getaddrinfo ENOTFOUND hostname

shaquer
25 May, 2023, 11:26

Okay after set api key and endpoint everything works.

safwan
25 May, 2023, 17:09

[SOLVED] Not able to create document with function

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