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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
sequeiraelton
Frequent Visitor

Cannot sign in with Anonymous Authentication for a Web API datasource

Hi,

 

I have been able to successfully connect and pull data through a Web API with anonymous authentication in Power BI desktop. However, after publishing it I cannot configure a scheduled refresh because the data source credentials gives me the following error message("Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again"). When I try to sign in it only gives a message - "Failed to update data source credentials". I have read some posts here and they mentioned that power bi service can authenticate to only one url - the root url. I updated my code accordingly but I still get the same error.

DataSource Credentials ErrorDataSource Credentials Error

Here is my code.

 

let
authToken = "Bearer abcdefg...",
Source = Json.Document(Web.Contents("https://emapi.site.com",[ Headers=[#"Authorization"=authToken],RelativePath="/v1/messages"]))
in
Source

 

Has anyone come across the same issue and resolved it? Thanks in advance.

 

4 REPLIES 4
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @sequeiraelton,

 

I have got a response from the Product team. Smiley Happy

 

Currently, “test connection” for web sources does not use any of the information in the options record, which in this case includes the authorization header that’s required for this source to respond. The service also doesn’t give the user a way to opt out of “test connection” or ignore its failures.

 

As a result, any query with a call to Web.Contents whose success is dependent on information in the options record cannot currently be scheduled for refresh in the service.

 

Regards

Thank you @v-ljerr-msft. I had raised an issue with the product team and I got the same response. On their recommendation I have gone ahead and submitted an improvement request. Depending on the number of votes, they will consider it for a fix/enhancement. I hope this either gains enough votes quickly or if they can expedite this request without waiting for votes to accumulate because the behaviour of the Web API is not uncommon. Here is the link to the improvement request I submitted.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/19202755-bypass-test-connection-i...

 

 

You can make it work with the relative path option provided the base URL returns good data without authentication. See this link for info:

 

https://community.powerbi.com/t5/Service/Anonymous-access/td-p/19136

 

 

Basically, take your root URL, and do a GET call in curl or a web browser, if you get back data then you should be fine. It worked for me, I have REST API data now auto refreshing using this method and pagination.

v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @sequeiraelton,

 

I have reproduced the same issue on my environment. I will report this issue internally, and post back if there is any feedback. Smiley Happy

 

Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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