Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

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

 Anonymous 

3 Replies