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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
stribor45
Post Prodigy
Post Prodigy

Paginate API with limit and start - cant apply field access to the type list

I am trying to adopt the code located on this page Paginate REST API  but I am receiving an error. Can someone assist with troubleshooting this error? I am receiving the error: 

 

Expression.Error: We cannot apply field access to the type List.
Details:
    Value=[List]
    Key=total_count

 

let 

    EntitiesPerPage = 100,
	Limit="_limit=" & Text.From(EntitiesPerPage),
    Url = "https://jsonplaceholder.typicode.com/comments?" & Limit,
    GetJson = (Url) =>
        let 			
            RawData = Web.Contents(Url),
            Json    = Json.Document(RawData)
        in  Json,
 
    GetEntityCount = () =>
        let Url   = Url & "&_start=0",
            Json  = GetJson(Url),
			Count = Json[#"total_count"]
        in  
			Count,
 
    GetPage = (Index) =>
        let 
			//(option A)offset equal to previous row count 
			offset  = "&_start=" & Text.From(Index * EntitiesPerPage),      
			Url   = Url & offset,
            Json  = GetJson(Url),
            Value = Json[#"jobs"]
        in  
			Value,
 
    EntityCount =  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

 

 

1 ACCEPTED SOLUTION
stribor45
Post Prodigy
Post Prodigy

I was able to figure out this so I will mark this as a solution.  I had to break down the code from the link above line by line to figure it out. It was long process. As an example this line 

 

Value = Json[#"jobs"]

 

In my case API provided the total so I had to call it differently

 

Value = Json[#"total_count"]

View solution in original post

2 REPLIES 2
stribor45
Post Prodigy
Post Prodigy

I was able to figure out this so I will mark this as a solution.  I had to break down the code from the link above line by line to figure it out. It was long process. As an example this line 

 

Value = Json[#"jobs"]

 

In my case API provided the total so I had to call it differently

 

Value = Json[#"total_count"]
stribor45
Post Prodigy
Post Prodigy

I had to go through each line of code and was able to get it working but had to block off #1 and #2. I can understand #1 since its pulling the count of only 10 records so it returns the value of 10 but it needs to pull the count of all records which is 500.  In #2 not sure why that piece of code was there. Can anyone comment on #1 and #2 please.

 

stribor45_0-1680719259986.png

stribor45_1-1680719322104.png

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.