Forum Discussion
PowerBI88
1 year agoResolver I
Dynamic query with next page key parameter from API - How to adapt code for Power BI service?
Hi, I am using a dynamic query in power bi desktop in order to extract all the rows from a Dynatrace API that lists all dynatrace problems. The Dynatrace api returns paginated results with a nextpag...
- 1 year ago
In the end, I solved my problem using a python script to import the data and write them in excel files.
Kind regards
Marta
PowerBI88
1 year agoResolver I
Hi, I followed the documentation but I still get the following error:
This dataset includes a dynamic data source. Since dynamic data sources aren't refreshed in the Power BI service, this dataset won't be refreshed. Learn more: https://aka.ms/dynamic-data-sources.
Here is the function call:
= let baseURL = "https://baseurl/api", endpoint = "/v2/problems", queryParams = [ pageSize = "500", from = "2024-01-01T00:00:01", to = "now" ], apiToken = "token", allProblems = getProblemAPIResult(baseURL, endpoint, apiToken, queryParams, null, {}) in allProblemshere is the recursive function with next page Key:
= let getProblemAPIResult = (baseURL as text, endpoint as text, apiToken as text, queryParams as record, nextPageKey as nullable text, collectedData as list) => let queryParamsWithPage = if nextPageKey <> null and nextPageKey <> "" then Record.Combine({queryParams, [nextPageKey = nextPageKey]}) else queryParams, apiResponse = Json.Document(Web.Contents( baseURL, [ RelativePath = endpoint, Query = queryParamsWithPage, Headers = [ Accept = "application/json; charset=utf-8", Authorization = "Api-Token " & apiToken ] ] )), newProblems = try apiResponse[problems]? otherwise {}, combinedData = List.Combine({collectedData, newProblems}), nextPage = try apiResponse[nextPageKey]? otherwise null, finalData = if nextPage = null then combinedData else getProblemAPIResult(baseURL, endpoint, apiToken, queryParams, nextPage, combinedData) in finalData in
getProblemAPIResult
Could you tell me where I am mistakening?
Thank you