Skip to content

Instantly share code, notes, and snippets.

@Fiser12
Last active April 13, 2022 14:46
Show Gist options
  • Select an option

  • Save Fiser12/759d004ceceeaacc75ac3addb9d18692 to your computer and use it in GitHub Desktop.

Select an option

Save Fiser12/759d004ceceeaacc75ac3addb9d18692 to your computer and use it in GitHub Desktop.
How to create a fast inbox that send your notes to the notion API
$NotionAPIKey=""
$DatabaseID=""
$Notionheaders = @{
"Authorization" = "Bearer $($NotionAPIKey)"
"Content-type" = "application/json"
"Notion-Version" = "2021-08-16"
}
function Post-To-Inbox {
$Input = Read-Host -Prompt 'Inbox:'
$json='{
"parent":{
"database_id":"$[DATABASE_ID]"
},
"properties":{
"Name":{
"title":[
{
"text":{
"content":"$[TEXT]"
}
}
]
}
}
}'.replace('$[TEXT]',$Input).replace('$[DATABASE_ID]',$DatabaseID)
if ($Input) {
$Result = Invoke-RestMethod -Uri "https://api.notion.com/v1/pages" -Method Post -Headers $Notionheaders -Body $json
Post-To-Inbox
} else {
exit;
}
}
Post-To-Inbox

How to configure the script?

You should add a shortcut that points to the file location

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File C:\Users\USER\Desktop\notion-inbox.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment