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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Refresh Dataset using API using C#.Net

Hi I was trying to refresh dataset using the Power Bi API and getting 401 Unauthrorized error message.

I was able to get the access tone by passing the parameters --(grant_type : "client_credentials"), (client_secret:XXXXXX)

The application is registred as Native client in Azure portal and granted Read/Write Dataset permission but still i was getting the error message -"The remote server returned an error: (401) Unauthorized."Please let me know if i need to post my code 

Thanks in advance 

 

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

Sorry for our late in response, We have test with the sameple code and it generated valid access token after we sign in as the users which have access to the dataset: https://docs.microsoft.com/en-us/power-bi/developer/automation/walkthrough-push-data-get-token, Does your Azure Access token generated by a sign in users?


Best regards,

 

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

I am using the below example in getting access token using the getAccessTokenSilently() method in c# using SSIS packages.

I have not installed any of the Microsoft.IdentityModel.Clients.ActiveDirectory dll's.

If i need to install Microsoft.IdentityModel.Clients.ActiveDirectory, can you please let me know the steps that i need to perform for the Visual studio(Business Intelligence) .

Thanks in Advance 

Example for Power REST API : 

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

Hi @Anonymous ,

 

Based on my research, if you want to use the example you shared, you may need install  Azure AD Authentication Library for .NET NuGet package first, it is included in this document: https://docs.microsoft.com/en-us/power-bi/developer/automation/walkthrough-push-data-get-token

 

  1. Install the Azure AD Authentication Library for .NET NuGet package. Your .Net app needs this package to get an authentication security token.

    a. Select Tools > NuGet Package Manager > Package Manager Console.

    b. Enter Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.21.301221612


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi , We have a c# code posting the parameters Grant Type, application Secret etc for genarating the access token and this works fine. while using the same token to refresh the data set i was getting 401 UnAuthorized error message.

The application is registered in Azure Portal and using power bi services ,granted api permissioins with Delegated user to Read/Write Dataset

 

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.