-
Notifications
You must be signed in to change notification settings - Fork 474
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
HTTP Invalid Input #357
Comments
looks like notionhq changed something on the backend :/ |
Same problem here ..:( |
I'm not sure this is related, but I noticed that if you visit a page's parent pages starting from the root, you are able to load it properly. So I have something like this in my code now: ancestors = {
'ded42785910b43349e7a406181f64475': [
'38ec63708e904d41a84c2985d745ee82',
'd1498e133e7d413085c936435449bdbb',
],
# ...
}
def visit_ancestors(client, page_id):
for ancestor_page_id in ancestors[page_id]:
client.get_block(ancestor_page_id).children
visit_ancestors(notion_client, page_id)
page = client.get_block(page_id)
# ... (except in reality, |
I have rewritten my use cases to consume the API directly. |
Ah nice! I haven't looked at the official API much. What is feature parity like? Is it similar enough? |
so the official API is very powerful and flexible. I am actually taking a stab at may be redoing this library to use the API. |
@ssvaddiparthy thanks that would be super awesome! I have felt similarly, but for now my fix above sorta works for me, so I've kind of de-prioritized it considerably. Last year, I wrote a layer on top of this unofficial API, e.g. import abc
from dataclasses import dataclass
from notion import block
class Block(abc.ABC):
@abc.abstractmethod
def append_to_page(self, page: block.Block) -> None:
pass
@dataclass(frozen=True)
class PageBlock(Block):
title: str
children: Sequence[Block]
icon: Optional[str] = None
def append_to_page(self, page: block.Block) -> None:
new_page = page.children.add_new(block.PageBlock, title=self.title)
if self.icon:
new_page.icon = self.icon
for child in self.children:
child.append_to_page(new_page)
@dataclass(frozen=True)
class VideoBlock(Block):
filepath: str
def append_to_page(self, page: block.Block) -> None:
page.children.add_new(block.VideoBlock).upload_file(self.filepath)
# ...
def append_to_page(new_block: Block, page_id: str) -> str:
page = client.get_block(page_id)
new_block.append_to_page(page)
return page.children[-1].id so I could do something like append_to_page(
new_block=PageBlock(
title='Blah',
children=[
TextBlock('Foo'),
TextBlock('Bar'),
VideoBlock(filepath=local_video_path),
],
),
page_id='1da9b81c7b964a6a9fb3187ba91d2f8b',
)) But it's sort of specialized for my use case, which is to always create new pages and/or append or prepend to pages. I never read data from Notion. |
The text was updated successfully, but these errors were encountered: