Created
July 27, 2023 15:02
-
-
Save tnvmadhav/bb781f28c4b7a129f2be61343418bc29 to your computer and use it in GitHub Desktop.
Python Client making HTTP request to Notion to add two columns and some data inside it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
url = "https://api.notion.com/v1/blocks/<your-block-id-here>/children" | |
payload = json.dumps({ | |
"children": [ | |
{ | |
"object": "block", | |
"type": "column_list", | |
"column_list": { | |
"children": [ | |
{ | |
"object": "block", | |
"type": "column", | |
"column": { | |
"children": [ | |
{ | |
"object": "block", | |
"type": "paragraph", | |
"paragraph": { | |
"rich_text": [ | |
{ | |
"type": "text", | |
"text": { | |
"content": "😀 Page 1", | |
"link": { | |
"url": "https://twitter.com/TnvMadhav" | |
} | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"object": "block", | |
"type": "column", | |
"column": { | |
"children": [ | |
{ | |
"object": "block", | |
"type": "paragraph", | |
"paragraph": { | |
"rich_text": [ | |
{ | |
"type": "text", | |
"text": { | |
"content": "😀 Page 2", | |
"link": { | |
"url": "https://twitter.com/TnvMadhav" | |
} | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
}) | |
headers = { | |
'Authorization': 'Bearer <Notion_Integration_Token>', | |
'Content-Type': 'application/json', | |
'Notion-Version': '2022-02-22', | |
} | |
response = requests.request("PATCH", url, headers=headers, data=payload) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment