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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

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, @Anonymous 

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors