Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Leggies
Frequent Visitor

How to setup the pagination next_page for all pages

Hi,

I'm trying to up the data from Zendesk through PowerBI, but i only get the first results. How do i setup the pagination in Power Query to get all results? I've tried with List.Generate, but i'm unable to succeed so far. Do you got a solution?

The Query tells me what the next_page and last_page is. 

The query is

let
Source = Json.Document(Web.Contents("https://xxxxxxxx.zendesk.com/api/v2/tickets.json?", [Headers=[Authorization="Basic ZGlXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]])),
#"Converted to Table" = Table.FromRecords({Source})
in
#"Converted to Table"

Leggies_0-1629715784074.png

 




6 REPLIES 6
v-xiaotang
Community Support
Community Support

Hi @Leggies 

did you try to click on expand button?

vxiaotang_0-1629874265805.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

@v-xiaotang i've tried, but it only gives the first 100 results. I'm trying to make a loop, but nothing works so far.

selimovd
Super User
Super User

Hey @Leggies ,

 

you have to loop through multiple API call.

Search in the community, that topic appeared many times. Also check the following video:

Pagination and DO/WHILE in Power BI / Power Query - YouTube

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hi @selimovd 

I tried, but its not working. I get the error "We cannot convert a value of type List to type Number." This is the Query:

let
Page = {1,1000},
Source = Json.Document(Web.Contents("https://xxxxxxx.zendesk.com/api/v2/tickets.json?page="&Number.ToText(Page), [Headers=[Authorization="Basic ZGlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]])),
#"Converted to Table" = Table.FromRecords({Source}),

List = List.Generate(() =>
[Result= try GetData(1) otherwise null, Page = 1],
each [Result] <> null,
each [Result = try GetData([Page]+1) otherwise null, Page =[Page]+1],
each [Result])

in
#"Converted to Table"

amitchandak
Super User
Super User

Hi @amitchandak ,

I've tried your solution, but i get the following error:

Expression.Error: The field '@odata.count' of the record wasn't found.
Details:
tickets=[List]
next_page=https://xxxxxxx.zendesk.com/api/v2/tickets.json?page=2
previous_page=
count=9758


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.