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?
1 Answer 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`,