Notion API returns 400 error when trying to retrieve page title

I’m working with the notion.py library and facing an issue while extracting page titles. My goal is to fetch a title from one Notion page and use it in another page, but I keep getting an HTTPError with status 400.

Here’s the error I’m encountering:

Traceback (most recent call last):
  File "notion_automation.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.

My current implementation looks like this:

from notion.client import NotionClient
import time

auth_token = "my_authentication_token"
notion_client = NotionClient(token_v2=auth_token)

source_page_url = 'source_page_link_here'
source_page = notion_client.get_block(source_page_url)

target_page_url = 'destination_page_link_here'
target_page = notion_client.get_block(target_page_url)

print(source_page.title)

What could be causing this 400 error when accessing page blocks?

Had this same problem a few months back with a similar automation. You’re probably passing the full URL when Notion wants just the page ID. Notion needs that specific 32-character UUID format - not the whole URL. Just grab the string after the last dash in your page URL. Also check if your token_v2 expired - they do that periodically. I had to pull a fresh one from browser dev tools when mine died. And make sure those pages are actually accessible with whatever auth level you’re using.

A 400 error usually means auth or permission problems, not URL issues. Your token_v2 might work for some stuff but lack permission for those specific pages. I’ve hit this before when trying to access pages shared with limited view access - API calls failed even though I could see the pages in my browser. Test with a page you definitely own first to see if it’s a token issue or page permissions. Workspace restrictions can also cause this even with valid tokens. The notion.py library gives terrible error messages for permission issues, so testing with your own page usually shows what’s really wrong.

just use the page ID instead of the full URL - grab that long string after the last slash. also, ditch notion.py since it’s basically dead now. the official Notion SDK is way better and doesn’t break every few weeks like the old library.

Been fighting Notion API issues for years and finally gave up on manual approaches.

You’re battling token management, API changes, and format quirks that break constantly. Even if you fix the page ID extraction and get fresh tokens, you’ll be back debugging similar problems in a few months.

I switched to Latenode for this stuff. It handles Notion connections automatically - extracts titles, updates pages, manages authentication. No more digging through dev tools for tokens or parsing URLs by hand.

Just set up the Notion trigger, add your source page, map the title to your destination, done. Takes 10 minutes instead of hours debugging Python libraries that’ll probably break next week.

Beats maintaining scripts that need constant fixes.

Also check your Notion client version. The notion.py library is deprecated and breaks with Notion’s current API. Switch to the official notion-client package - that’s what fixed my 400 errors. And verify page permissions since private pages can throw random errors.

Check if you’re using workspace pages vs personal pages. I hit this same error when my automation tried accessing pages in a shared workspace where I only had member access, not admin rights. The token_v2 worked fine for my personal stuff but threw 400 errors on workspace content. You might need a fresh token while logged into that specific workspace, or get an admin to give you proper API access. Also, some enterprise Notion setups completely block programmatic access - that’d explain why the same code works in one place but not another.

Everyone’s suggesting Python library fixes, but you’ll keep hitting the same walls.

The real problem? Notion’s API is unstable and changes auth requirements randomly. I’ve seen this error pattern dozens of times - fix the page ID today, token expires tomorrow, permissions change next week.

Stop debugging Python libraries and scraping tokens from browser dev tools every month. Just automate it properly.

I use Latenode for all my Notion stuff now. Simple workflow that grabs the title from your source page and updates the target. No token management, no URL parsing, no library headaches.

Runs reliably without me babysitting auth issues or chasing API changes. Takes 15 minutes to set up vs hours debugging code that’ll break again.

Way more reliable than maintaining scripts for an API that throws random 400 errors.