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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors