I’m working with the notion.py library as a beginner in Python and I’m facing difficulties when trying to retrieve titles from Notion pages. I want to get the title from one page and display it on another page, but I keep running into an HTTPError stating “Invalid input”.
Here’s the error message I’m seeing:
Traceback (most recent call last):
File "notion_page_reader.py", line 12, in <module>
source_page = notion_client.get_block(source_page_url)
File "/usr/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 "/usr/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 "/usr/local/lib/python3.6/site-packages/notion/store.py", line 184, in get
self.call_load_page_chunk(id)
File "/usr/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 "/usr/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.
This is the code I’m using:
from notion.client import NotionClient
import time
auth_token = "my_authentication_token"
notion_client = NotionClient(token_v2=auth_token)
source_page_url = 'url_of_source_page'
source_page = notion_client.get_block(source_page_url)
destination_page_url = 'url_of_destination_page'
destination_page = notion_client.get_block(destination_page_url)
print(source_page.title)
What could be the reason for this 400 error, and how can I effectively retrieve page titles?