Created
August 25, 2021 12:04
-
-
Save sandoche/c7b5ca70503d2e396923ed082bc98906 to your computer and use it in GitHub Desktop.
Notion API - Creating page with image
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
curl 'https://api.notion.com/v1/pages' \ | |
-H 'Authorization: Bearer '"SECRET_HERE"'' \ | |
-H "Content-Type: application/json" \ | |
-H "Notion-Version: 2021-05-13" \ | |
--data '{ | |
"parent": { | |
"type": "page_id", | |
"page_id": "PAGE_ID_HERE" | |
}, | |
"properties": { | |
"title": { | |
"title": [{ "type": "text", "text": { "content": "A note from your pals at Notion" } }] | |
} | |
}, | |
"children": [ | |
{ | |
"object": "block", | |
"type": "paragraph", | |
"paragraph": { | |
"text": [{ "type": "text", "text": { "content": "You made this page using the Notion API. Pretty cool, huh? We hope you enjoy building with us." } }] | |
} | |
}, | |
{ | |
"object": "block", | |
"type": "image", | |
"image": { | |
"caption": [], | |
"type": "file", | |
"file": { | |
"url": "https://undesign.learn.uno/icon.png", | |
"expiry_time": "2021-08-26T22:12:29.066Z" | |
} | |
} | |
} | |
] | |
}' |
The problem came from Notion-Version to 2021-08-16
And also the type was not correct here is the right code:
curl 'https://api.notion.com/v1/pages' \
-H 'Authorization: Bearer '"SECRET"'' \
-H "Content-Type: application/json" \
-H "Notion-Version: 2021-08-16" \
--data '{
"parent": {
"page_id": "PAGE_ID"
},
"properties": {
"title": {
"title": [{ "type": "text", "text": { "content": "A note from your pals at Notion" } }]
}
},
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"text": [{ "type": "text", "text": { "content": "You made this page using the Notion API. Pretty cool, huh? We hope you enjoy building with us." } }]
}
},
{
"object": "block",
"type": "image",
"image": {
"caption": [],
"type": "external",
"external": {
"url": "https://undesign.learn.uno/icon.png"
}
}
}
]
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this error: