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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
vikrant7677
Regular Visitor

Urgent: Refreshing power report C#

Hi. I am making a C# script (Windows console application on VS 2017) to refresh the dataset/report which I already have in my workspace. I do not wish to do it manually(scheduled refresh) because the process will be automated(Azure data factory). so the C# script needs to be executed as a Azure data factory pipeline. thus I want to refresh my dataset/report programmatically. 

Please guide me.. I am new to C#.. I am following the way mentioned in the below link:

https://community.powerbi.com/t5/Developer/Data-Refresh-by-using-API-Need-Steps/td-p/208928

when I execute the C# code I get an error saying remote server returned 401 forbidden..I dont know how do I proceed.I am registering an app on dev.powerbi.com and make a native app.. I dont know what exactly should my redirect url be? I think that is where I am going wrong. please guide me. I am totally confused.thanks in advance 

2 REPLIES 2
Molotch
Helper II
Helper II

So, I haven't look into this very much but it seems as in your scenario you should just create a regular account in Azure AD, give it a PowerBI Pro license and use that login/password in your code to retrieve a access token and use that in the authorization header when you call the REST-api.

 

Look at the section Access token for non-Power BI users (app owns data)

https://docs.microsoft.com/en-us/power-bi/developer/get-azuread-access-token

 

No need to setup a registered app with a oauth flow since you're not building an application that should consume data on behalf of the user.

 

Here you can check how they use the token to call the API.

 

https://github.com/guyinacube/PowerBI-Developer-Samples/blob/master/App%20Owns%20Data/PowerBIEmbedde...

 

I've never tried it though so I might be way off. Might give it a try this week if I have some time left.

ill try this too. could you please try and let me know exactly how can I proceed? I get error 401 when I execute the link in the above thread.

thanks

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors