The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
Solved! Go to Solution.
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"]
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"]
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.