I am fetching the data from an API of sumo-logic which gives me limited results in response max=100 and provides "nextPageToken" to fetch other results.
In postman we can directly access it by placing "nextPageToken" in request URL but in Power BI how to implement and automate this function, I don't have any idea.
I have tried some M-queries on my own but it is resulting error : "Expression.Error: The import FetchAllPages matches no exports. Did you miss a module reference?"
let // Define a recursive function to fetch all pages FetchAllPages = (url as text, nextPageToken as nullable text) as list => let // Construct URL with nextPageToken if it exists FullUrl = if nextPageToken <> null then url & "&nextPageToken=" & nextPageToken else url, // Fetch data from the URL Source = Json.Document(Web.Contents(FullUrl)), // Assuming 'data' and 'nextPageToken' are directly accessible in the JSON structure DataObjects = Source[data][objects], NewNextPageToken = try Source[data][nextPageToken] otherwise null, // Recurse if nextPageToken exists, else return the current list of objects Result = if NewNextPageToken <> null then List.Combine({DataObjects, FetchAllPages(url, NewNextPageToken)}) else DataObjects in Result, // Initial API URL (make sure to adjust URL as per your API requirements) BaseUrl = "https://api.sumologic.com/api/sec/v1/insights/all", // Start fetching data from the first page AllData = FetchAllPages(BaseUrl, null), // Convert the list of records to a table FinalTable = Table.FromList(AllData, Splitter.SplitByNothing(), null, null, ExtraValues.Error)in FinalTable
please need to solve it.