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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
abedkhooli
Frequent Visitor

Refreshing a Restful Data Source with API Key

I have a REST API data source which I connected to successfully from Power BI Desktop (using Feb. version).  When I publish to service (free), I can't refresh: "Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again".

In the Data Source Credentials / edit credentials, I have 3 options: anonymous, windows and basic. No option to enter key.

In desktop, I finally used (had to use parameters as a work around for refresh and #"param" for the "-" char):

Source = Json.Document(Web.Contents("https://api......./messages/topic", 
[RelativePath = "/.....141", ApiKeyName = "api-key", 
Query = [#"start-date" = dt5, #"end-date" = dt2 ] ])),

and entered the key in the interface (web api). I also tried sending it in header: Headers=[Authorization="api-key <key>"]. 

Is refresh for this scenario supported in service?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @abedkhooli,

Based on my research,  using the ApiKeyName option isn't supported in the Power BI service .

And if the root URL of the your api works with anonymous access, you can publish the report that uses the Headers option to pass an API key and the refresh should work in Power BI Service. However, if your root URL returns error with anonymous access, refresh in Power BI Service will fail, you can use fso’s workaround that execute the query elsewhere and connect Power BI to that as a data source.

Thanks,
Lydia Zhang

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @abedkhooli,

Based on my research,  using the ApiKeyName option isn't supported in the Power BI service .

And if the root URL of the your api works with anonymous access, you can publish the report that uses the Headers option to pass an API key and the refresh should work in Power BI Service. However, if your root URL returns error with anonymous access, refresh in Power BI Service will fail, you can use fso’s workaround that execute the query elsewhere and connect Power BI to that as a data source.

Thanks,
Lydia Zhang

Thank you @Anonymous for the tip. I just kept the root part of the url (public but redirects to html file) and add the rest to relative path. so, it reads:

 Source = Json.Document(Web.Contents("https://api.***.io/", 
[RelativePath = "v1/*****141", Headers=[Authorization="api-key 42****c4"],
Query = [#"start-date" = dt5, #"end-date" = dt2 ] ])),

When published to service, it did not refresh at first and gave same error. However, went to settings and edit credentials, signed in as anonymous (accepted) and it worked. Hopefully, this will be sorted out in future updates.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.