Forum Discussion

toovishant's avatar
toovishant
Helper II
1 year ago
Solved

Rest API connecting to Power BI

Hi Team, I am trying to connect Rest API to Power BI. Currently I am using below query trying to connect via "Blank Query" But below query gives only 10k records. Also when I try to connect WEB, no...
  • v-kpoloju-msft's avatar
    v-kpoloju-msft
    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 Learn

    If 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.