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

get_collection_view returning None

Open diallobakary4 opened this issue 4 years ago • 9 comments

The code below works well in modifying a page. But it keeps on returning None when I try to access a database.

from notion.client import NotionClient
client = NotionClient(token_v2=token)
# Replace this URL with the URL of the page you want to edit
page = client.get_block("https://www.notion.so/xxx")
print("The old title is:", page.title)
# Note: You can use Markdown! We convert on-the-fly to Notion's internal formatted text data structure.
page.title = "The title has now changed, and has *live-* in the !"


task_database = "https://www.notion.so/xxx?v=xxx"
cv = client.get_collection_view(task_database)
print(cv)

diallobakary4 avatar Oct 21 '20 20:10 diallobakary4

I think it's not only collections, get() on page returns none:

page
Out[22]: <PageBlock (id='removed', title='Academic Web Page from Notion using Hugo')>
print(page.get())
None

Successfully created page returns None when get() called.

AlexMikhalev avatar Oct 25 '20 20:10 AlexMikhalev

I am not having this problem with get_collection_view

WardBenjamin avatar Nov 10 '20 02:11 WardBenjamin

@WardBenjamin interesting, what is your notion py version and how do you use it?

AlexMikhalev avatar Nov 10 '20 09:11 AlexMikhalev

@AlexMikhalev looks like 0.0.25, latest on PyPI. Both client.get_block(url) and client.get_collection_view(url) are working for me, with URLs in the format of https://www.notion.so/xxxx?v=yyyy

Except for embedded images, all of the read API's that I've tried so far seem to be working for me. Something about the security policy on the image requests is also broken, as are quite a few other things about the library (most of the write/sync APIs, particularly anything that calls submitTransaction since Notion seems to only use saveTransaction in the web version). It seems like waiting until the official release might be the only real option if you want to do anything more than reading text.

WardBenjamin avatar Nov 10 '20 13:11 WardBenjamin

Thank you, I hacked my way around lack of raw response, I will be waiting for next release.

AlexMikhalev avatar Nov 11 '20 10:11 AlexMikhalev

FYI for those interested, I had this exact issue and resolved it...by pip install notion

rather than pip install notion-py

Not exactly a fix, but hopefully a workaround for those who were scratching their heads like me

bisaacs42 avatar Nov 26 '20 11:11 bisaacs42

The same for me. My investigations are:

# the collection id in notion-py is 'raw' format
LINK = "https://www.notion.so/some_org/70b752520eec4ab0a58d20ec85553228?v=f11274fabdeb41bfb3383f24a5e2672f"
client = NotionClient(token_v2=TOKEN_V2)
cv = client.get_collection_view(DB_LINK)
# the collection id is 70b752520eec4ab0a58d20ec85553228
# but in browser the collection id is 0b3de74d-630c-489e-bf0d-059f23e41e06

Installing notion not notion-py helps, thanks @bisaacsdfs.

ag0n1k avatar Jan 05 '21 06:01 ag0n1k

had to make the Notion page public for this to work for me

odeckmyn avatar Jan 16 '21 12:01 odeckmyn