jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.3k stars 475 forks source link

raise InvalidNotionIdentifier(input_value) #384

Open robotbird opened 1 year ago

robotbird commented 1 year ago
from notion.client import NotionClient

# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in (non-guest) session on Notion.so
client = NotionClient(token_v2="tonken_from_header")

# Replace this URL with the URL of the page you want to edit
page = client.get_block("https://robotbird.notion.site/test-f4808828a06543aebb115fd03cc700d3")

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-updated* in the browser!"

The error message is as follows

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/notion/utils.py", line 37, in extract_id
    return str(uuid.UUID(url_or_id))
  File "/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/uuid.py", line 177, in __init__
    raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/robotbird/Works/yepeng/works/notion4u/test.py", line 7, in <module>
    page = client.get_block("https://robotbird.notion.site/test-f4808828a06543aebb115fd03cc700d3")
  File "/opt/homebrew/lib/python3.10/site-packages/notion/client.py", line 168, in get_block
    block_id = extract_id(url_or_id)
  File "/opt/homebrew/lib/python3.10/site-packages/notion/utils.py", line 39, in extract_id
    raise InvalidNotionIdentifier(input_value)
notion.utils.InvalidNotionIdentifier: https://robotbird.notion.site/test-f4808828a06543aebb115fd03cc700d3
image