vaphes/pocketbase

[Question] Unable to run simple query to fetch a document from a collection

Closed this issue · 3 comments

Hi, I have this collection containing the following docs:

image

I'm trying to fetch an article where exhausted === False

# fetch a test article where exhausted is false
article = client.collection("articles").get_list(
    1, 20, {"filter": 'exhausted = false"'})
print('article', article.items[0])

but it keeps failing here?

ne 37, in _get_list
    response_data = self.client.send(
                    ^^^^^^^^^^^^^^^^^
  File "C:\_repo\python_pocket_base\.venv\Lib\site-packages\pocketbase\client.py", line 109, in send
    raise ClientResponseError(pocketbase.utils.ClientResponseError: Response error. Status code:403

Have I used the correct syntax to fetch?

Hi,

Errors 403 is caused by wrong authentication.

Verify if you are logged with correct user before.

Try login with your admin user to test.

Thanks, yeah that was it 🤦

I did not set this rule to 'Set custom rule'

image

how to fetch and see data like this
root@minx-Lenovo-V145-14AST:/home/minx/belajar/colongan/pythonsidik# python3 test.py
<Record: 85oeuawmpqdm44y>
<Record: l99wjn9094c2193>

my code
import asyncio
from pocketbase import PocketBase

client = PocketBase('http://127.0.0.1:8090')

admin_data = client.admins.auth_with_password("xxx@gmail.com", "admxxxxin12345")

result = client.collection("fletSample").get_full_list()

for x in result:
print(x)