Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change queryCollection request payload and response parsing #352

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

wsykala
Copy link
Contributor

@wsykala wsykala commented Oct 7, 2021

#350

This change works for table views, but it might not work for other types (for example board view).

@pavelapekhtin
Copy link

pavelapekhtin commented Oct 7, 2021

Did not seem to fix it for me, or am i doing it wrong?

merging it like this
pip install git+https://github.com/jamalex/notion-py.git@refs/pull/352/merge

and it fails at get_rows() with raise HTTPError( requests.exceptions.HTTPError: Invalid input.

client = NotionClient(token_v2=v2_token)
page = client.get_block(page_url)
cv = client.get_collection_view(page_url)

for row in cv.collection.get_rows(search='Q'):
....

@guillaumefrd
Copy link

Thanks, it worked for my table view!

@wsykala
Copy link
Contributor Author

wsykala commented Oct 7, 2021

The issue is that the request payload for queryCollection endpoint changed and it looks like it has different structure depending on the type of collection you are trying to get rows from. Below is an example from the collection that I am getting using my scripts:

{
  "collection":{
    "id":"collection-id",
    "spaceId":"space-id"
  },
  "collectionView":{
    "id":"collection-view-id",
    "spaceId":"space-id"
  },
  "loader":{
    "type":"reducer",
    "reducers":{
      "collection_group_results":{
        "type":"results",
        "limit":"limit"
      },
      # This looks to be optional and it takes the aggregates
      # No idea how the name is generated though
      "table:uncategorized:title:count":{}
    },
    "sort":[],
    "searchQuery":"",
    "userTimeZone":""
  }
}

I will take a look later and try to make it work for other types, but it might be hard.

@pavelapekhtin Could you try to run get_rows() without any arguments and see if it works?

@pavelapekhtin
Copy link

@wsykala same story unfortunately

tried it also outside for loop too

@felipehlvo
Copy link

It also worked in my board view!

raphodn added a commit to raphodn/notion-py that referenced this pull request Oct 7, 2021
@arturmesquitab
Copy link

Thanks, works for me as well!

@wsykala
Copy link
Contributor Author

wsykala commented Oct 10, 2021

Might fix some of the issues mentioned in #351

Copy link

@infraredgirl infraredgirl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and confirm it fixes the issue!

@alexattia
Copy link

Working for me! Would be great if it could be merged

@thomashirtz
Copy link

thomashirtz commented Nov 18, 2021

When will it be merged ? It is quite annoying to have buggy notion-py out of the box ..

@ashutoshsaboo
Copy link

+1, can you please merge these changes @wsykala given now the PR has been approved as well by both reviewers?

@wsykala
Copy link
Contributor Author

wsykala commented Nov 21, 2021

@ashutoshsaboo I would love to do it but I don't have write access to the main repository so I can't merge it

@ashutoshsaboo
Copy link

cc'ing repo owner, @jamalex could you please help get this PR merged? notion-py seems to be broken rn without this fix..

ashutoshsaboo pushed a commit to ashutoshsaboo/notion-py that referenced this pull request Nov 22, 2021
@srepollock
Copy link

Is there a timeline for when this will be merged in?

@wsykala
Copy link
Contributor Author

wsykala commented Feb 16, 2022

Updated to address #365 (comment)

@laserroger
Copy link

laserroger commented Mar 19, 2022

Hi, under this case how can we use filters in cv.build_query()?
I checked that in store.py, call_query_collection, the filter is not used in the data.

@laserroger
Copy link

Now I can only do the filtering via the "integration" method suggested by the notion official API. The v2 token doesn't work for this method even after formatting the filter properly and embedding it into the store.py's data in the call_query_collection .

hcshin90 pushed a commit to hcshin90/notion-py that referenced this pull request Aug 17, 2022
chrisjune and others added 3 commits March 4, 2023 11:02
@jamalex
Copy link
Owner

jamalex commented Oct 25, 2023

Thanks all, and sorry that I haven't been able to attend to this project due to capacity. Trying to get some of the key PRs like this merged in now to get the base version functional again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.