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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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