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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
monkeysocks
Frequent Visitor

API limited to 50 responses - pagination looping required

Hi,

 

I hope that you are well. I am really struggling to find a solution to pull more than 50 records from an API endpoint. Essentially I need to keep looping the call until all rows have been pulled.


I have found plenty of examples for Json but am struggling for Xml, any help to get this to dynamically loop until all records have been pulled rather than using the offset argument (as per the developer docs) with a static row number would be greatly appreciated.


Current Query:

 

 

let
    Source = Xml.Tables(Web.Contents("https://vcc-eu10b.8x8.com/api/stats/agents")),
    Table0 = Source{0}[Table],
    #"Changed Type" = Table.TransformColumnTypes(Table0,{{"agent-id", type text}, {"group-id", Int64.Type}, {"date-hired-date", type text}, {"direct-agent-access", type text}, {"email-address", type text}, {"enabled", type text}, {"first-name", type text}, {"full-name", type text}, {"last-name", type text}, {"phone-used", type text}, {"workplace-phone", type text}, {"phone-extension", Int64.Type}, {"login-id", type text}, {"user-rights", type text}, {"voice-mail-activated", type text}, {"agent-to-agent-chat-disabled", type text}, {"max-concurrent-customer-chat", type text}, {"deleted", type logical}}),
    #"Expanded workplace-SIP" = Table.ExpandTableColumn(#"Changed Type", "workplace-SIP", {"Element:Text"}, {"workplace-SIP.Element:Text"})
in
    #"Expanded workplace-SIP"

 

 

Source:

monkeysocks_0-1630516383321.png

Expanded:

monkeysocks_1-1630516443815.png


API developer documentation:
Pagination

Requests that would return a large number of records will respond with 50 records per request. You can iterate through these response sets by setting the {offset} argument. In this example, we are asking for agent interactions, starting with the 101st record.

http://vcc-na4.8x8.com/api/stats/agent/rws/interactions?n=101

 

"VCC APIs have a max return of 50 entries. To get the next 50 entries, the API request will have to be modified to return rows starting at 51.

For example: https://vcc-eu2.8x8.com/api/stats/queues?n=51"


Thanks in advance for any assistance or guidance

1 ACCEPTED SOLUTION

Hard to know without being able to drill into that table to see if there is an overall count in there, or if there is a separate type of call you can make to get the count (e.g., /$count").  If you know how many records to expect another way, you can just make your List.Numbers go past that and then have a Remove Errors step to get rid of the ones that went too far, before you expand the data.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Please see this video for how to do this.

Power BI - Tales From The Front - REST APIs - YouTube

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you very much Pat, this is a really great video. I have 1 slight issue which is probably me looking in the wrong area or doing the wrong thing (so apologies in advance for my ignorance). I can only receive as Xml or CSV not Json. So when I create the query my source looks like the below and does not provide the pagination info like in the video, so I have nothing at present to base the required number of iterations off. 

monkeysocks_0-1630569847441.png

What should I be doing differently to pull that info?

 

Thanks in advance

Hard to know without being able to drill into that table to see if there is an overall count in there, or if there is a separate type of call you can make to get the count (e.g., /$count").  If you know how many records to expect another way, you can just make your List.Numbers go past that and then have a Remove Errors step to get rid of the ones that went too far, before you expand the data.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi Pat,

 

There wasn't a call available for the count so I went with the List.Numbers and Remove Errors Option and it worked perfectly. Thank you very much for your help!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors