Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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:

Housden96_0-1678195001169.png

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:

Housden96_1-1678195082675.png

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 2
artemus
Employee
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.

Anonymous
Not applicable

So the issue is I need the API Key within the M Query due to an auto refresh so you're suggesting I do the following:

Web.Contents("https://api.breathehr.com/v1/departments/104295/absences?per_page=100&page=",

[Query = [Param1 = Number.ToText(Page)]] , [Headers=[#"X-API-KEY"="prod-APIKeyHere"]])),

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors