Forum Discussion

jimbob2285's avatar
jimbob2285
Advocate IV
1 year ago
Solved

Can't refresh dynamic API URL in Power BI service

Hi   I have a paginated API data source in a Power BI report, that used the following M code to iterate through and combine multiple pages into a single table, but I then can't refresh the report o...
  • v-ssriganesh's avatar
    v-ssriganesh
    1 year ago

    Hello jimbob2285,
    Thanks for getting back and for providing those additional details.

    You're absolutely on the right track using RelativePath with Web.Contents is the correct solution to make your API call refreshable in the Power BI Service. You're very close, and the issue now seems to be related to how the parameters and authentication are being passed in the M code.

    Key things to check:

    • Keep your BaseUrl simple and static. It should not include parameters or dynamic segments.
    • Use RelativePath only for the fixed portion of the endpoint path like /v1/organizations.
    • Pass start, limit, and api_token using the Query option as a record. This is critical Power BI expects query parameters to be passed in this structured format to allow refresh in the Service.
    • Avoid string concatenation inside RelativePath or Query. These should be clearly separated.
    • If your API uses an API key in the query string, include it in the Query record as well. If it uses headers, you’ll need to configure it using the Headers option inside Web.Contents.

    Here are two official docs that explain this pattern clearly:

  • v-ssriganesh's avatar
    v-ssriganesh
    1 year ago

    Hello jimbob2285,
    Thanks for sharing more details, you're really close. The issue now is with how the Query parameter is being passed.

    Power BI expects Query to be in a structured format using key-value pairs, not as a single concatenated string like "api_token=XXXX". This is a common roadblock. Instead of building one string, you should treat each query parameter as a separate item in a list (or "record") so Power BI can safely handle them and construct the URL properly for both Desktop and Service refresh.