Forum Discussion
Ricardo_MSS
5 years agoHelper II
Help applying Query and Relative path to avoid dynamic data source for Service refresh
Hi All, I've a function built to paginate through an API call. It works very well on the Desktop service but when trying to refresh on PBI Service the following error is displayed: ...
v-janeyg-msft
5 years agoCommunity Support
Ricardo_MSS
5 years agoHelper II
Hi v-janeyg-msft ,
This now work to call the information correctly. Unforetunately Still has an issue with refresh in PBI Service.
(ProjectID as text) =>
let iterations = 20,
Bookmark1 = "0",
url = "https://field.dalux.com/service/APIv2",
Repath = "FieldRestService.svc/v2.2/Projects/"&ProjectID&"/Approvals",
Q = [key="API KEY", bookmark= Bookmark1],
FnGetOnePage= (url) as record =>
let Source = Json.Document(Web.Contents(url,[RelativePath=Repath, Query=Q])),
data = try Source[ApprovalsList] otherwise null,
bookmark = try Source[NextBookmark] otherwise null,
res = [Data = data, Bookmark = bookmark]
in res,
GeneratedList = List.Generate(
() =>
[i=0, res = FnGetOnePage(url)],
each [i] < iterations,
each [i=[i]+1, Bookmark1 = [res][Bookmark], res = FnGetOnePage(url)],
each [res][Data] ),
#"Converted to Table" = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1", {"CreatedByUser", "CreatedDateTime", "ExtensionsDataList", "InspectionType", "IsDeleted", "LocationList", "Project", "ApprovalID", "ApprovalNumber", "ApprovalRevisionList"}, {"Column1.CreatedByUser", "Column1.CreatedDateTime", "Column1.ExtensionsDataList", "Column1.InspectionType", "Column1.IsDeleted", "Column1.LocationList", "Column1.Project", "Column1.ApprovalID", "Column1.ApprovalNumber", "Column1.ApprovalRevisionList"})
in
#"Expanded Column2"
Maybe the ProjectID has to be hard coded?
If that funtion is modified to only pull bookmarks for each project. These could be recombined in a new column.
A function could then be invoked using the full url as parameter. In theory the url / source would not be dynamic.
I'll try that out see how it goes.