1

I've tried to create Scriptable widget using Notion API. I need to get count of page inside DB.

So, I used guide to create token and share DB, and by this guide I create cURL request:

 curl 'https://api.notion.com/v1/databases/%DB_ID%/query' \
 -H 'Authorization: Bearer %TOKEN%' \
 -H 'Notion-Version: 2021年05月13日' \
 --data '{
 "filter": 
 {
 }
 }'

The filter in body is required, without this param you will get error.

So, the curl works fine.


Then I've tried to create scriptable code:

async function notion_fetchData() {
 const url = 'https://api.notion.com/v1/databases/%DB_ID%/query'
 request = new Request(url)
 request.headers = {'Authorization':Bearer ${todoist_Api_key}, 'Notion-Version': '2021-05-13'}
 request.body = Data.fromString('{"filter": {}}')
 const res_notion = await request.loadJSON()
 console.log(res_notion)
 return res_notion
}

And this code gets error: "resource exceeds maximum size". Any ideas how to debug this error?

Sabaoon Bedar
3,7752 gold badges34 silver badges41 bronze badges
asked Aug 4, 2021 at 13:59

1 Answer 1

1

With the help of the Slack community, we find the answer is that on iOS13, it is not allowed to add a body in GET request. To make it work again, we can either switch to a POST/PUT request or add body value via url parameters of the GET request.

Code in official notion js client:

const databasesQuery = {
 //POST instead GET
 method: "post",
 pathParams: ["database_id"],
 queryParams: [],
 bodyParams: ["filter", "sorts", "start_cursor", "page_size"],
 path: (p) => `databases/${p.database_id}/query`,
answered Aug 4, 2021 at 20:29
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.