====== Integrate Notion ======
===== Add integrations =====
* Login your Notion account on browser
* Open https://www.notion.so/my-integrations
* Click button 'Add integration'
* Set a name, like 'For Testing'
* Set the following options
{{ :interview:interview_agenda:integrate_notion:screen_shot_2022-10-25_at_19.03.23.png?1000 |}}
* After that you will get a 'Integration Token'
===== Set an Integration for Notion Page =====
{{ :interview:interview_agenda:integrate_notion:screen_shot_2022-10-25_at_19.09.10.png?800 |}}
===== Use postman to test API =====
==== Get database id ====
* Use browser to open the Notion Page
* Get the id from url
{{ :interview:interview_agenda:integrate_notion:screen_shot_2022-10-25_at_19.15.01.png?1200 |}}
* The id is ''498e7f9d5c244016af1abf53978272e3''
==== Get one database ====
* Reference https://developers.notion.com/reference/post-database-query
POST https://api.notion.com/v1/databases/{database_id}/query
Headers
Authorization: Bearer
Body
{
"filter": {
"and": [
{
"property": "Interview Email",
"checkbox": {
"equals": false
}
},
{
"property": "Email time",
"date": {
"after": "2022-10-22T22:30:00.000+08:00",
"before": "2022-10-25T22:40:00.000+08:00"
}
},
{
"property": "Status",
"select": {
"equals": "Pending"
}
},
{
"property": "Post",
"select": {
"does_not_equal": "QA"
}
},
{
"property": "Post",
"select": {
"does_not_equal": "Design"
}
}
]
}
}
* Get result like that, so that we can get each page id
{{ :interview:interview_agenda:integrate_notion:screen_shot_2022-10-25_at_21.07.09.png?600 |}}
==== Update one Page ====
* Reference https://developers.notion.com/reference/patch-page
PATCH https://api.notion.com/v1/pages/{page_id}
Headers
Authorization: Bearer ,
Notion-Version: 2022-06-28
Body
{
"properties": {
"Interview Email": {
"checkbox": true
}
}
}