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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
anneke
New Member

Error refreshing API data in PowerBI Service

I have made an model where there is data retrieved with an API. The API is called multiple times, and it's done with the following code in the advanced editor: 
response = try Web.Contents("[API LInk]", [Headers=headers, RelativePath = SiteID  Query = [group_id = GroupID,page_size = "1000", period = DateText]]) otherwise null,

I can refresh the data in Power BI Desktop, but when I try this in on app.powerbi.com I get the following error: Expression.Error: Failed to retrieve data from API. . The exception was raised by the IDbCommand interface.

How can I fix this error?

Thanks in advance!

3 REPLIES 3
Anonymous
Not applicable

Hi, @anneke 

First of all, make sure that the authentication method used in Power BI service is consistent with that used in Power BI Desktop. Check if Api has a rate limit or timeout setting. Power BI service is likely to trigger these restrictions more often than Power BI desktop. You can also use tools like Postman to independently test the Api call. This helps to verify whether the problem is with Api itself or the way Power BI service handled the request.
You can also refer to the following links:

Troubleshoot Power BI REST APIs - Power BI | Microsoft Learn

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sergej_og
Super User
Super User

The most tricky part to call API from Service is to define the [RelativePath]-part and then the [Query]-part.
Do you have the correct split (into base-url, RelativePath, Query) of your url you'd like to call?

Regards

Jonvoge
Super User
Super User

Hi anneke

 

API refreshes in the Service is a tricky topic indeed.

Without understanding your error fully, I have a hunch it is related to the engine not being able to return a static result from your base URL.

 

Chris Webb has some excellent resources on the topics:

Chris Webb's BI Blog: Using The RelativePath And Query Options With Web.Contents() In Power Query An...

Chris Webb's BI Blog: Web.Contents, Text Concatenation And Dataset Refresh Errors In Power BI/Power ...

Chris Webb's BI Blog: Web.Contents(), M Functions And Dataset Refresh Errors In Power BI (crossjoin....

 

Perhaps trying one his tricks mught do it for you!

_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Find me on LinkedIn, Sessionize, or my blog Downhill Data

Helpful resources

Announcements
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.