jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.28k stars 476 forks source link

NotionValidationError: Invalid input when calling .get_rows() #353

Open geraldtayyj opened 2 years ago

geraldtayyj commented 2 years ago

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 :/

ymmu commented 2 years ago

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 .. ??

arturmesquitab commented 2 years ago

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

wsykala commented 2 years ago

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

ymmu commented 2 years ago

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

geraldtayyj commented 2 years ago

@wsykala works for me as well. Thank you!

alexattia commented 2 years ago

Works for me too