jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.3k stars 475 forks source link

search_blocks not working? #400

Open emmby opened 4 months ago

emmby commented 4 months ago
from notion.client import NotionClient

if __name__ == "__main__":
    client = NotionClient(token_v2=...)
    print(client.get_top_level_pages())
    print(client.search_blocks(search='foobar'))

Printing get_top_level_pages() works fine. Printing search_blocks(search='foobar') results in a 400:

Traceback (most recent call last):
  File "/Users/mike/Documents/GitHub/underline/functions_py/test.py", line 7, in <module>
    print(client.search_blocks(search='underline'))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mike/Documents/GitHub/underline/functions_py/venv/lib/python3.12/site-packages/notion/client.py", line 321, in search_blocks
    return self.search(query=search, limit=limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mike/Documents/GitHub/underline/functions_py/venv/lib/python3.12/site-packages/notion/client.py", line 359, in search
    response = self.post("search", data).json()
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mike/Documents/GitHub/underline/functions_py/venv/lib/python3.12/site-packages/notion/client.py", line 260, in post
    raise HTTPError(
requests.exceptions.HTTPError: Something went wrong. (400)

This is using notion-py@c3c9c25