Back

API not getting document

  • 0
  • Databases
  • Cloud
Ryan
14 Jan, 2024, 08:36

so basically, I need to get a document from appwrite database. as u can see in the picture, there are many documents, with their IDs. the DB ID is env_vars and collection ID is key-value-pairs. I try to access ENVHUB_API_KEY and it gives 404 saying document not found. Why? my code:

TypeScript
from appwrite.services.databases import Databases
from appwrite.client import Client
client = Client()
key = Databases(client).get_document("env_vars", "key-value-pair", "ENVHUB_API_KEY")
TL;DR
Developers are experiencing an issue where they are trying to retrieve a document from the Appwrite database but are receiving a 404 error stating that the document cannot be found. They have checked and confirmed that the database ID and collection ID are correct. They are using Python to access the document. Solution: It appears that there is a typo in the code. The collection ID is listed as "key-value-pairs" but is referenced as "key-value-pair" in the code. The correct code should be: ```py key = Databases(client).get_document("env_vars", "key-value-pairs", "ENV
Ryan
14 Jan, 2024, 08:50

proof that the DB ID and Collection ID is correct:

Emerson
14 Jan, 2024, 08:51

Are you setting the Appwrite endpoint? Is it the ID of your project?

Ryan
14 Jan, 2024, 08:52
TypeScript
(client
    .set_endpoint('https://cloud.appwrite.io/v1')
    .set_project('envhub')
)
Emerson
14 Jan, 2024, 08:52

Are you setting the ID of your project?***

Ryan
14 Jan, 2024, 08:52

.set_project("envhub") sets it, so yes

Emerson
14 Jan, 2024, 08:52

it's node.js?

Ryan
14 Jan, 2024, 08:52

python

Ryan
14 Jan, 2024, 08:53

python

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