Action

Notion: List Pages

Posted by agiletortoise, Last update over 2 years ago

List pages shared with the Drafts integration in your Notion workspace. Meant only as a demo of making basic calls with the Notion script object.

For more information on Notion integration, see our Notion Integration Guide

Steps

  • script

    // list pages which have been shared with the Drafts integration
    // API Docs: https://developers.notion.com/reference/post-search
    let endpoint = "https://api.notion.com/v1/search"
    
    // create Notion instance to make request
    // 'filter' property specifies only page object
    let notion = Notion.create();
    let response = notion.request({
    	"url": endpoint,
    	"method": "POST",
    	"data": {
    		"filter": {
    			"value": "page",
    			"property": "object"
    		}
    	}
    });
    
    // result has JSON payload
    // with page properties
    if (response.statusCode == 200) {
    	alert(`Notion Pages Loaded:
    	
    ${JSON.stringify(response.responseData, null, 2)}`)
    }
    else {
    	alert(`Notion Error: ${response.statusCode}
    	
    ${notion.lastError}`);
    	context.fail();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.