-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33330b7
commit edde69e
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import requests | ||
from django.conf import settings | ||
|
||
# Replace these with your details | ||
NOTION_TOKEN = settings.NOTION_TOKEN | ||
|
||
|
||
def fill_database(database_id): | ||
headers = { | ||
"Authorization": f"Bearer {NOTION_TOKEN}", | ||
"Content-Type": "application/json", | ||
"Notion-Version": "2022-06-28", # Use the correct version of the API | ||
} | ||
|
||
# Payload to create a new row | ||
payload = { | ||
"parent": {"database_id": database_id}, | ||
"properties": { | ||
"Name": {"title": [{"text": {"content": "Sample Row"}}]}, | ||
"Status": {"select": {"name": "In Progress"}}, | ||
"Date": {"date": {"start": "2025-01-15"}}, | ||
}, | ||
} | ||
|
||
# Make the API request | ||
response = requests.post( | ||
"https://api.notion.com/v1/pages", headers=headers, json=payload | ||
) | ||
|
||
# Check response | ||
if response.status_code == 200: | ||
print("Row added successfully!") | ||
else: | ||
print("Failed to add row:", response.status_code, response.text) |
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
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