1

I am using notion-client, a package that lets you use the notion api in python (the link is here: https://pypi.org/project/notion-client/).

My goal is to add text (e.g. "i just added this block of text, thanks to the notion api") to a to do list page where there is already some things written in bullet points: buy chicken breasts; see the definition of oedipus.

To accomplish this goal, i am following the following tutorial: https://developers.notion.com/docs/working-with-page-content

I've written the following code:

from pprint import pprint
from notion_client import Client

token = "00000000000000000000000" #censored token for security reasons
notion = Client(auth=token)

page_id = "000000000000000000"  # the to do list page. it is also censored for security reasons

blocos_pagina = notion.blocks.children.list(page_id) # the to do list page is a block and the bullet lines containing, for example "buy chicken breasts" is a children of the block

# the problem is in the following lines:
# basically the following lines are to add content to the to do list page. In this example, for testing purposes, i want to add a hyperlink called notion api team that redirects to a twitter account

texto = notion.blocks.children.append({
    "block_id": page_id,
    "children": [
        {
            object: 'block',
            type: 'paragraph',
            "paragraph": {
                "text": [
                    {
                        "type": 'text',
                        "text": {
                            "content": '– Notion API Team',
                            "link": {
                                "type": 'url',
                                "url": 'https://twitter.com/NotionAPI',
                            },
                        },
                    },
                ],
            },
        },
    ],
}
)

The output of this code is:

APIResponseError: Invalid request URL.

Robert
  • 7,394
  • 40
  • 45
  • 64
appwiz.cpl
  • 19
  • 1
  • You're page_id is probably incorrect. Ensure that it doesn't include a `?` and anything after that. Review the "Where can I find my page's ID?" [section](https://developers.notion.com/docs/working-with-page-content). – Isaac Pak Feb 09 '23 at 14:52

0 Answers0