Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Structuring a web API to refresh in Power BI Online

Good afternoon all

 

I am currently trying to format my M query so I can upload a report and the connected web link using the advanced section to contain the API Key will refresh. I managed to get this all working within Power BI but I am unable to format the M Query to work for relative path data this was my original code below:

I then attempted to update the code to use a relative path to make this possible update on Power BI Pro but with no luck:

When this runs it returns the API data, due to it being Paginated I run the following script to pull it into one table:

 

= List.Generate(()=>
[Result = try #"Proclaim Absences"(1) otherwise null, Page=1],
each [Result] <> null,
each [Result = try #"Proclaim Absences"([Page]+1) otherwise null, Page=[Page]+1],
each [Result])

 

Any assistance would be appreciated on how to get this working, it's a pain not being able to validate the API call in Power BI Data sets!

2 Replies

  • artemus's avatar
    artemus
    Microsoft Employee

    RelativePath is used if you need to add part of the url before the parameters (?). To add dynamic parameter use the Query option.

    e.g.

     

    Web.Contents("https://example.com", 
       [Query = [param1 = "1", param2 = "test"],
       ApiKey = "X-API-KEY"
       ])

     

     

    Note: As shown in the example above, it is recommended to not include key tokens in your power query, and instead use the ApiKey to indicate the name of the key parameter, and then use ApiKey authentication when you connect.