Forum Discussion
API Pagination using has_more & next_cursor responses in an Post call
Hi,
API Newbie here. I have been able to make a 'post' call to the notion api in power query. Now I am trying to call to the next page with the provided next_cursor reponses as part of the body parameter 'start_cursor'.
Here is my M function (my attempt at a 2nd call is commented out):
Let
AuthKey = "myAuthKey",
url="https://api.notion.com/v1/databases/myDBID/query",
body="{""Sorts"":""created_time""}",
Source = Json.Document(Web.Contents(url,[
Headers = [#"Authorization"=AuthKey ,
#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
)),
//hasMore = Source[has_more],
//nextCursor = Source[next_cursor],
// body2 = "{""start-cursor"":"& nextCursor &",}",
// Source2 = Json.Document(Web.Contents(url,[
// Headers = [#"Authorization"=AuthKey ,
// #"Content-Type"="application/json"],
// Content = Text.ToBinary(body2)
// ]
// )),
results = Source[results]
in
results
And here is the notion API docs: Pagination (notion.com)
Could someone please point me in the right direction? Should I be using a function?
Thanks
Hannah
1 Reply
- AnonymousNot applicable
Anonymous
I am not sure about 'start_cursor'. But here is a detailed explanation of implementing API pagination using count, top, and skip: How To Do Pagination In Power Query | by Mark Tiedemann | Medium
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.