简体   繁体   中英

can't get page title from notion using api

I'm using notion.py and I'm new to python I want to get a page title from page and post it in another page but when I try I'm getting an error

Traceback (most recent call last):
  File "auto_notion_read.py", line 16, in <module>
    page_read = client.get_block(list_url_read)
  File "/home/lotfi/.local/lib/python3.6/site-packages/notion/client.py", line 169, in get_block
    block = self.get_record_data("block", block_id, force_refresh=force_refresh)
  File "/home/lotfi/.local/lib/python3.6/site-packages/notion/client.py", line 162, in get_record_data
    return self._store.get(table, id, force_refresh=force_refresh)
  File "/home/lotfi/.local/lib/python3.6/site-packages/notion/store.py", line 184, in get
    self.call_load_page_chunk(id)
  File "/home/lotfi/.local/lib/python3.6/site-packages/notion/store.py", line 286, in call_load_page_chunk
    recordmap = self._client.post("loadPageChunk", data).json()["recordMap"]
  File "/home/lotfi/.local/lib/python3.6/site-packages/notion/client.py", line 262, in post
    "message", "There was an error (400) submitting the request."
requests.exceptions.HTTPError: Invalid input.

My code is that I'm using is

from notion.client import NotionClient
import time
token_v2 = "my page tocken"
client = NotionClient(token_v2 = token_v2)
list_url_read = 'the url of the page page to read'
page_read = client.get_block(list_url_read)
list_url_post = 'the url of the page'
page_post = client.get_block(list_url_post)
print (page_read.title)

You can find the fix here

In a nutshell you need to modify two files in the library itself:

  1. store.py
  2. client.py

Find "limit" value and change it to 100 in both.

It isn't recommended to edit source code for dependencies, as you will most certainly cause a conflict when updating the dependencies in the future.

Fix PR 294 has been open since the 6th of March 2021 and has not been merged.

To fix this issue with the currently open PR (pull request) on GitHub, do the following:

pip uninstall notion

Then either:

  1. pip install git+https://github.com/jamalex/notion-py.git@refs/pull/294/merge

OR in your requirements.txt add

  1. git+https://github.com/jamalex/notion-py.git@refs/pull/294/merge

Source for PR 294 fix

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM