Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Error with Post request to Notion API

Topic Labels: Scripting extentions
Solved
Jump to Solution
12725 10
cancel
Showing results for 
Search instead for 
Did you mean: 
Zack_S
8 - Airtable Astronomer
8 - Airtable Astronomer

Trying to make a post request to Notion to create a new page. Receiving an Error 400 Bad Request and can’t find the issue.

Here’s the documentation - Create a page
and script below

let payload = {
    'parent': {
        "type": "page_id",
        "page_id": "my page id"
    },
    'properties': {
        "Name": {
            "type": "title",
            "title": [{ "type": "text", "text": { "content": "My Page Title" } }]
        }
    }
};



let response = await remoteFetchAsync(postUrl, {
    method: 'POST',
    body: JSON.stringify(payload),

    headers: {
        'Notion-Version': '2022-06-28',
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`,
    },
});

output.text('**POST RESPONSE**' + ' - ' + response.status)
10 Replies 10

Thanks for the update. I guess I’ve just got my own issues with Notion’s wording. :winking_face:

As for the issue you encountered, there might be some deeper reason why a database ID worked where a page ID didn’t. Without knowing a lot more about your specific setup, though, it’s tough to say why.