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
Anonymous
Not applicable

API JSON URL LIMIT 5000

Hi Guys, I need your help. I am fetching data from vsts.contents.  I am getting only 5000 records but it contains more than 5000 records. I used this code from chrome but also it is not working. I don't know where is the mistake.

 

let 
    BaseUrl         = "https:dev.azure.com/XXXX/xxxxx/_apis/build/builds?api-version=5.0",
    EntitiesPerPage = 5000,
 
    GetJson = (Url) =>
        let RawData = VSTS.Contents(Url, Options),
            Json    = Json.Document(RawData)
        in  Json,
 
    GetEntityCount = () =>
        let Url   = BaseUrl & "&$count=true&$top=0",
            Json  = GetJson(Url),
            Count = Json[count]
        in  Count,
 
    GetPage = (Index) =>
        let Skip  = "&$skip=" & Text.From(Index * EntitiesPerPage),
            Top   = "$top=" & Text.From(EntitiesPerPage),
            Url   = BaseUrl & Skip & "&" & Top,
            Json  = GetJson(Url),
            Value = Json[value]
        in  Value,
 
    EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
    PageCount   = Number.RoundUp(EntityCount / EntitiesPerPage),
    PageIndices = { 0 .. PageCount - 1 },
    Pages       = List.Transform(PageIndices, each GetPage(_)),
    Entities    = List.Union(Pages),
    Table       = Table.FromList(Entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
    Table

 @v-yuezhe-msft 

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can refer this simliar issue about returning more rows in power query when using URL:

https://community.powerbi.com/t5/Power-Query/API-JSON-URL-10-000-row-limitation/m-p/1491105

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PhilipTreacy
Super User
Super User

Hi @Anonymous 

That code as it is is not valid.  The BaseURL is missing // in https:// and Options in the VSTS.Contents call is not defined.  I don't see how it is working for you to return 5000 records?

If you have another query that is returning 5000 records, what are the values of EntityCount and  PageCount?  These determine the number of calls made to the API.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


mahoneypat
Employee
Employee

Please see this video for one way to do this.

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

 

Regards,

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


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.

Top Solution Authors
Top Kudoed Authors