Forum Discussion
Rest API connecting to Power BI
- 1 year ago
Hi toovishant,
Thank you for sharing the details and walking us through your approach.
From your explanation, it looks like you’re trying to loop through multiple pages of a REST API using List.Generate, which is a valid strategy in Power Query. That said, if the loop isn't working as expected, there are a few areas worth reviewing:
Variable Evaluation in List.Generate: Ensure that the PageNumber used inside your FetchPage function is properly updated in each iteration. In Power Query, the way state is passed in List.Generate can sometimes lead to unexpected behavior if not carefully handled.
Termination Logic: You’re using a hardcoded MaxPages = 10, which is fine for testing, but in production, it’s more reliable to exit based on actual data e.g., when a returned page has fewer than the expected PageSize or is empty.
Function Output Validation: It might help to validate if FetchPage() returns what you expect (a list, table, or record) and whether the "results" field always exists. A missing field or mismatched structure could silently break the loop.
Diagnostics: As a next step, consider testing your FetchPage() function independently for a couple of page numbers to verify consistency in the returned structure. That will help isolate whether the issue is with pagination or with the base fetch.
Kindly refer to the below documentation link for better understanding:
List.Generate - PowerQuery M | Microsoft LearnIf you have any questions regarding this, please feel free to reach out to us. We will be happy to help you. If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you for using Microsoft Community Forum.
Which REST API is that? Does it come with documentation?
That's right, I have to reffer the Documentation via Swagger API does this help?
- lbendlin1 year agoSuper User
Do you have a link to the documentation?