Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hi @Anonymous ,
I am calling powerBI rest APIs using C# with authentication. I can able to get datasets and groups using PowerBIClient class. While executing ExecuteQueryInGroup method gives me bad request error.
Below is the sample code to generate token and getting datasets and groups using PowerBIClient API class.
AuthenticationResult? authenticationResult = null;
IEnumerable<string> scopes = new string[] { "https://analysis.windows.net/powerbi/api/.default" };
var tenantSpecificUrl = "https://login.microsoftonline.com/tenent_Id/oauth2/token";
PublicClientApplication clientApp = PublicClientApplicationBuilder.Create("appId").
WithAuthority(tenantSpecificUrl).WithClientId("clientId").Build();
var userAccounts = clientApp.GetAccountsAsync().Result;
try
{
if (userAccounts == null)
{
authenticationResult = clientApp.AcquireTokenSilent(scopes, userAccounts?.FirstOrDefault()).ExecuteAsync().Result;
}
else
{
authenticationResult = clientApp.AcquireTokenByUsernamePassword(scopes, "username", "password").ExecuteAsync().Result;
}
}
catch (MsalUiRequiredException)
{
}
return authenticationResult.AccessToken;
Get Dataset and Use Below Code to ExecuteQueries
DatasetExecuteQueriesResponse datasetExecuteQueriesResponse =
client.Datasets.ExecuteQueriesInGroup(new Guid("xxxxx"),
"xxxxx", datasetDatasetExecuteQueriesRequest);
The above code give me error "Operation returned an invalid status code 'BadRequest'"
Can someone help what am I missing here?
Hi @Coder86 ,
Can you please share some more detail information about this issue? They should help us clarify your scenario and test to troubleshoot.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 6 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |