notion-py icon indicating copy to clipboard operation
notion-py copied to clipboard

NotionValidationError: Invalid input when calling .get_rows()

Open geraldtayyj opened this issue 4 years ago • 6 comments

Recently I have been getting a notion.client.NotionValidationError: Invalid #input. error when trying to get_rows() from my collection view. Below is the code to illustrate:

from notion.client import NotionClient
from dotenv import load_dotenv
import os

load_dotenv()
client = NotionClient(token_v2=os.getenv("NOTION_V2_APIKEY"))
tasklist = client.get_collection_view(os.getenv("TASKLIST"))

for row in tasklist.collection.get_rows():
  if (row.get_property("status") == "Done 🙌"):
    print("Done")

However I get the following error:

  File "C:\Users\User\app.py", line 27, in update
    for row in cv.collection.get_rows():
  File "C:\Python39\lib\site-packages\notion\block\collection\basic.py", line 163, in get_rows
    return self.query(**kwargs)
  File "C:\Python39\lib\site-packages\notion\block\collection\basic.py", line 151, in query
    return CollectionQuery(self, self._get_a_collection_view(), **kwargs).execute()
  File "C:\Python39\lib\site-packages\notion\block\collection\query.py", line 60, in execute
    self._client._store.call_query_collection(
  File "C:\Python39\lib\site-packages\notion\store.py", line 354, in call_query_collection
    data = self._client.post("queryCollection", data).json()
  File "C:\Python39\lib\site-packages\notion\client.py", line 716, in post
    raise NotionValidationError(msg, extra=res_data)
notion.client.NotionValidationError: Invalid input.

What went wrong? This code was working a few days ago :/

geraldtayyj avatar Oct 09 '21 18:10 geraldtayyj

Me too. I replaced my code with issue #294 but it doesn't work. Was something changed in req payload form of notion.so/api/v3/queryCollection .. ??

ymmu avatar Oct 10 '21 05:10 ymmu

Same to me. Smoke test fails at this part as well.

arturmesquitab avatar Oct 10 '21 07:10 arturmesquitab

I did a quick fix that works for some views (#352). Does it work for you @ymmu @penguinoob ?

wsykala avatar Oct 10 '21 08:10 wsykala

@wsykala Oh, it works for me as well when trying to get data from the table ! Thank you so much for fix ! ;))

ymmu avatar Oct 10 '21 09:10 ymmu

@wsykala works for me as well. Thank you!

geraldtayyj avatar Oct 10 '21 09:10 geraldtayyj

Works for me too

alexattia avatar Oct 11 '21 09:10 alexattia