Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Dear all,
i'm currently confronted with a pagination issue when getting data from a REST Apo.
When querying the REST API with a custom query i get the total of pages in return, but the query is repeating the data from the first page, and it doesn't return fetch the data from the others pages.
The custom query im using
let
BaseUrl = "--",
Token = "--",
EntitiesPerPage = 50,
GetJson = (Url) =>
let
Options = [Headers=[access_token="--", Accept="--", #"Content-Type"="--"]],
RawData = Web.Contents(BaseUrl, 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 = "$offset=" & Text.From(Index * EntitiesPerPage),
Url = BaseUrl & Skip,
Json = GetJson(Url),
Value = Json[#"items"]
in Value,
EntityCount = List.Max({ EntitiesPerPage, GetEntityCount() }),
PageCount = Number.RoundUp(EntityCount / EntitiesPerPage),
PageIndices = { 0 .. PageCount - 1 },
Pages = List.Transform(PageIndices, each GetPage(_)),
#"Converted to Table" = Table.FromList(Pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1", {"href", "id", "firstName", "lastName"}, {"Column1.href", "Column1.id", "Column1.firstName"})
in
#"Expanded Column2"
I'm a newbie in Power Query so kindly ask your support & suggestions on how to resolve this issue.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.