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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |