vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
359 stars 41 forks source link

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

Closed ryanrosello-og closed 1 year ago

ryanrosello-og commented 1 year ago

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?

paulocoutinhox commented 1 year ago

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.

ryanrosello-og commented 1 year ago

Thanks, yeah that was it 🤦

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

image

bobwatcherx commented 1 year ago

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

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)