The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
5 | |
5 | |
2 | |
2 | |
2 |
User | Count |
---|---|
10 | |
7 | |
4 | |
4 | |
4 |