Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I am an average Power BI user and a novice in Power Query coding.
I'm trying to get data to make a report from this API integration Query cases - Cases (torq.io).
The data I obtain is divided into multiple pages. The paging method is based on a next_page_token provided by the previous request and must be entered in JSON format in the body of the next POST request.
I am able to get the first page but so far I have not been able to bring me the rest of the pages.
Here the code that I'm trying:
let
Url = "https://api.torq.io/public/v1alpha/cases/query",
Token = "vvvvvvvvvv-wwwwwwwwww-xxxxxxxxxxx-yyyyyyyyyyy-zzzzzzzzzzz",
initial_body ="{
""filters"": {
""created_at"" : {
""relative"" : ""RELATIVE_LAST_12_HOURS""
}
},
""order"" : ""dsc"",
""order_by"" : ""created_at"",
""page_size"" : 500
}",
body_json = Json.Document (initial_body),
Options = [Headers = [
Authorization = "Bearer " & Token,
#"Content-Type"="application/json",
#"Accept"="application/json"
],
Content = Json.FromValue(body_json)
],
RawData = Web.Contents (Url,Options),
InitialWebCall = Json.Document(RawData),
datalist = List.Generate(() => InitialWebCall,
each List.Count([next_page_token]) <> null,
each try Json.Document(Web.Contents(
Url,
[
Headers = [Authorization = "Bearer " & Token, #"Content-Type"="application/json",#"Accept"="application/json"],
{
"page_token" : HOW CAN GET PREVIOUS TOKEN PAGINATION??
}
]))
otherwise [next_page_token = {}], each [next_page_token]),
in
datalist
I don't know how to put the paging token from the previous query into the body of the new query in JSON format.
Any suggestions?
Thank you very much in advance.
Hi @luisrco
Based on your description, you can refer to the following link, it describes how to implement pagination in power query.
How To Do Pagination In Power Query | by Mark Tiedemann | Medium
And you can refer to the following similar thread
Solved: Pagination with Rest API query and JSON file - Microsoft Fabric Community
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.