Forum Discussion
makpaul
5 years agoNew Member
Unable to get all data from the source after changing to RelativePath method
The following code works fine and could get all data from the source. Yet, it is unable to refresh on PowerBI web.
let
iterations = 150,
url = "https://sjc1.qualtrics.com/API/v3/mailinglists/mailing-list-id/contacts/",
FnGetOnePage = (url) =>
let
Source = Json.Document(Web.Contents(url, [Headers=[#"X-API-TOKEN"="token here"]])),
data = try Source[result][elements] otherwise null,
next = try Source[result][nextPage] otherwise null,
res = [Data=data, Next=next]
in
res,
GeneratedList =
List.Generate(
()=>[i=0, res = FnGetOnePage(url)],
each [i]<iterations and [res][Data]<>null,
each [i=[i]+1, res = FnGetOnePage([res][Next])],
each [res][Data]),
GeneratedList1 = GeneratedList{0}
in
GeneratedList1
I tried to change the code to use RelativePath method instead for getting source data so to see if it could be refreshed on PowerBI web but I found that it cannot obtain all the data from the source as the above method does.
let
iterations = 150,
url = "https://sjc1.qualtrics.com/",
FnGetOnePage = (url) =>
let
Source = Json.Document(Web.Contents(url, [RelativePath="API/v3/mailinglists/mailing-list-id/contacts/?skipToken=", Headers=[#"X-API-TOKEN"="token-here"]])),
data = try Source[result][elements] otherwise null,
next = try Source[result][nextPage] otherwise null,
res = [Data=data, Next=next]
in
res,
GeneratedList =
List.Generate(
()=>[i=0, res = FnGetOnePage(url)],
each [i]<iterations and [res][Data]<>null,
each [i=[i]+1, res = FnGetOnePage([res][Next])],
each [res][Data]),
GeneratedList1 = GeneratedList{0}
in
GeneratedList1
I would like to ask what further modification is needed to allow PowerBI to get all data from the source normally.
Thank you.
1 Reply
- Nathaniel_C
Community Champion