jamalex / jamalex/notion-py

"collection.get_rows()" doesn't work.

Open
#355 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4.4k
Forks
470
PR merge metrics
No merged PRs in 30d

Description

I created a table for a test and tried to choose row using "collection.get_rows()".
But I saw an error like below. I couldn't understand this error. Please help.
I work on JupyterNotebook with Mac(macOS High Sierra), and browser is google chrome.

```
import json
from notion.client import NotionClient
from notion.block import *
TOKEN_V2 = "TOKEN_V2"
WORKSPACE_URL = "WORKSPACE_URL"
BLOCK_URL = "BLOCK_URL"

client = NotionClient(token_v2=TOKEN_V2)

link = WORKSPACE_URL
page = client.get_block(link)

cv = client.get_collection_view(BLOCK_URL)
sample_text = "a"
permission_row_ = cv.collection.get_rows(search=sample_text)

---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/var/folders/bk/kxtjncm13ss694ydsp7hqmcw0000gn/T/ipykernel_78495/1373521628.py in
1 sample_text = "a"
----> 2 permission_row_ = cv.collection.get_rows(search=sample_text) #権限を与える行を選択 (ブロックの中で)

/usr/local/lib/python3.8/site-packages/notion/collection.py in get_rows(self, **kwargs)
237
238 def get_rows(self, **kwargs):
--> 239 return self.query(**kwargs)
240
241 def _convert_diff_to_changelist(self, difference, old_val, new_val):

/usr/local/lib/python3.8/site-packages/notion/collection.py in query(self, **kwargs)
234
235 def query(self, **kwargs):
--> 236 return CollectionQuery(self, self._get_a_collection_view(), **kwargs).execute()
237
238 def get_rows(self, **kwargs):

/usr/local/lib/python3.8/site-packages/notion/collection.py in execute(self)
408 return result_class(
409 self.collection,
--> 410 self._client.query_collection(
411 **kwargs
412 ),

/usr/local/lib/python3.8/site-packages/notion/client.py in query_collection(self, *args, **kwargs)
292
293 def query_collection(self, *args, **kwargs):
--> 294 return self._store.call_query_collection(*args, **kwargs)
295
296 def as_atomic_transaction(self):

/usr/local/lib/python3.8/site-packages/notion/store.py in call_query_collection(self, collection_id, collection_view_id, search, type, aggregate, aggregations, filter, sort, calendar_by, group_by, limit)
343 }
344
--> 345 response = self._client.post("queryCollection", data).json()
346
347 self.store_recordmap(response["recordMap"])

/usr/local/lib/python3.8/site-packages/notion/client.py in post(self, endpoint, data)
258 )
259 )
--> 260 raise HTTPError(
261 response.json().get(
262 "message", "There was an error (400) submitting the request."

HTTPError: Invalid input.

```

![Screen Shot 2021-10-13 at 20 38 05](https://user-images.githubusercontent.com/82034464/137129754-a7c8d326-507c-4f57-b40c-ed9709469226.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the shown call in the Jupyter Notebook, then inspect notion/collection.py around get_rows(), query(), and CollectionQuery.execute(). Trace the request into notion/store.py at call_query_collection() and compare the generated query inputs with the failing response. Done means the sample search returns rows or reports a clear, actionable error.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, macos, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.