如何用Notion API(Python)读取块提及?2022-06-28版本暂不支持
编辑说明:该功能目前暂不支持(Notion版本:2022-06-28)
我用Python 3开发集成工具,用来重新格式化已录入的Notion页面,但发现粘贴其他块的链接并选择「提及块」后,通过API读取不到对应块的文本内容。父页面已经添加到我的集成中,但接口返回的富文本是空的。
目前页面提及、用户提及都能正常读取,只有块提及不行——是不是这个功能暂不支持?
我用GET请求访问https://api.notion.com/v1/blocks/{block_id},请求头如下:
{ "Authorization": f"Bearer {NOTION_SECRET}", "Content-Type": "application/json", "Notion-Version": "2022-06-28", }
这是它在Notion中的显示效果:
复制链接后选择“提及块”选项的显示截图
我期望提及的块返回内容如下:
{ "archived": False, "bulleted_list_item": { "color": "default", "rich_text": [ { "annotations": { "bold": False, "code": False, "color": "default", "italic": False, "strikethrough": False, "underline": False, }, "href": None, "plain_text": "This is my test block I want to mention it later", "text": { "content": "This is my test block I want to mention it later", "link": None, }, "type": "text", } ], }, "has_children": False, "object": "block", "type": "bulleted_list_item", # etc. }
但实际包含提及的行返回内容是这样的:
{ "archived": False, "bulleted_list_item": { "color": "default", "rich_text": [ { "annotations": { "bold": False, "code": False, "color": "default", "italic": False, "strikethrough": False, "underline": False, }, "href": None, "plain_text": "In this line, I will mention the block before by right-clicking, using the “Copy link to block” action, then pasting and selecting the “Mention block” action: ", "text": { "content": "In this line, I will mention the block before by right-clicking, using the “Copy link to block” action, then pasting and selecting the “Mention block” action: ", "link": None, }, "type": "text", } ], }, "has_children": False, "object": "block", "type": "bulleted_list_item", # etc. }
如果是单独的提及行,返回内容则为:
{ "archived": False, "bulleted_list_item": { "color": "default", "rich_text": [ { "annotations": { "bold": False, "code": False, "color": "default", "italic": False, "strikethrough": False, "underline": False, }, "href": None, "plain_text": " ", "text": {"content": " ", "link": None}, "type": "text", } ], }, "has_children": False, "object": "block", "type": "bulleted_list_item", # etc. }
内容的提问来源于stack exchange,提问作者LetMeAdam
相关产品推荐
相关产品推荐

