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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ChrisWeeks92
Helper I
Helper I

Refreshing data from REST API

Hi

 

I have a REST API setup as one of my datasets.  What is the best way to get it to schedule refreshes, say 3x a day like 8am,12pm,3pm to capture the latest data in my report.  

 

My REST API code is as follows.  Is there a line i should add to the API code or any other way that i can get this to update automatically. 

 

let    
url = "API LINK HERE", 
body = "{""Username"": ""xxxxxxxx"", ""Password"": ""xxxxxxxx"", ""CustomerID"": ""x""}",   

Source  = Json.Document(Web.Contents(url,   [ 
     Headers = [#"Content-Type"="application/json"],
     Content=Text.ToBinary(body)   
]   
)   
),
in
    #"Renamed Columns1"
4 REPLIES 4
v-micsh-msft
Microsoft Employee
Microsoft Employee

Have you tried to follow the article below to configure Shceduled Refresh?

Configuring scheduled refresh

 

If yes, what is the error messages?

 

If there are errors popped out, please share it here.

 

The code you posted should be the connection string stored in Power BI Desktop, which belongs to the web contents, please check the article below and see if it would work in your scenario:

Dynamic Web.Contents() and Power BI Refresh Errors

 

Regards,

Michael

Hi 

 

Sorry for the delay, i have been busy on other projects.  

 

I have just tried Scheduled refresh as below.  It comes back with 

 

Failed to update data source credentials: Web.Contents failed to get contents from 'API URL' (405): Method Not AllowedHide details

 

I do have a personal gateway setup for this as i think it mentions that it would need a personal data gateway too but it comes back with "Your data source can't be refreshed because the credentials are invalid. Please update your credentials and try again." I have tried my Microsoft ID, API username/password and my computer login details.  so any help will be much appreciated to where i am going wrong.

 

I don't quite understand where your second article is referencing in my case, what should i add/change in my file to refresh the API without actually opening the file and refreshing the data.  

 

Thanks

Chris

Did this get resolved? I am having same issue. 

Yes this did get resolved.  It was the configuration of the API on the developers side.  The developer had fixed the API for me.  

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.