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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sanjeevgaut
Frequent Visitor

PowerBIClient does not have any value.

I am trying to read powerbi report using powerbi SDk. I got correct access token (tested in postman). Same access token is passed for TokenCredentials. but not getting any value in _powerBIClient. it has no value. i am using below code.

 

 

var functionCred = new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential(_configuration[BotConfigurationEnum.FunctionClientId.GetDescription()], _configuration[BotConfigurationEnum.FunctionClientSecret.GetDescription()]);

var userAssertion = (!string.IsNullOrWhiteSpace(token)) ? new Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion(token, "urn:ietf:params:oauth:grant-type:jwt-bearer") : null;

var context = new AuthenticationContext("https://login.microsoftonline.com/{tenentid}");
var res = await context.AcquireTokenAsync("https://analysis.windows.net/powerbi/api",
functionCred, userAssertion);

var tokenCredentials = new TokenCredentials(res.AccessToken, "Bearer");

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);
var pbiReport = _powerBIClient.Reports.GetReport(reportId);

 Any help appreatiated. @Anonymous

Thanks

1 ACCEPTED SOLUTION
sanjeevgaut
Frequent Visitor

Instead of 

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);

added below and it worked.

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com"), tokenCredentials);

 

View solution in original post

2 REPLIES 2
sanjeevgaut
Frequent Visitor

Instead of 

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);

added below and it worked.

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com"), tokenCredentials);

 

V-lianl-msft
Community Support
Community Support

Hi @sanjeevgaut ,


Are you using ClientCredentials (Service principal)?

Do you enable the service principal for the workspace in Tenant settings and add the security group as an admin of the PowerBI workspace?


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors