<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PowerBiClient executequeries giving 'BadRequest' response. in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerBiClient-executequeries-giving-BadRequest-response/m-p/3466183#M44842</link>
    <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Below is the sample code to generate token and getting datasets and groups using PowerBIClient API class.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AuthenticationResult? authenticationResult = null;&lt;BR /&gt;IEnumerable&amp;lt;string&amp;gt; scopes = new string[] { "&lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;" };&lt;BR /&gt;var tenantSpecificUrl = "&lt;A href="https://login.microsoftonline.com/tenent_Id/oauth2/token" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/tenent_Id/oauth2/token&lt;/A&gt;";&lt;/P&gt;&lt;P&gt;PublicClientApplication clientApp = PublicClientApplicationBuilder.Create("appId").&lt;BR /&gt;WithAuthority(tenantSpecificUrl).WithClientId("clientId").Build();&lt;BR /&gt;var userAccounts = clientApp.GetAccountsAsync().Result;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;if (userAccounts == null)&lt;BR /&gt;{&lt;BR /&gt;authenticationResult = clientApp.AcquireTokenSilent(scopes, userAccounts?.FirstOrDefault()).ExecuteAsync().Result;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;authenticationResult = clientApp.AcquireTokenByUsernamePassword(scopes, "username", "password").ExecuteAsync().Result;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (MsalUiRequiredException)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;return authenticationResult.AccessToken;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Get Dataset and Use Below Code to ExecuteQueries&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DatasetExecuteQueriesResponse datasetExecuteQueriesResponse =&lt;BR /&gt;client.Datasets.ExecuteQueriesInGroup(new Guid("xxxxx"),&lt;BR /&gt;"xxxxx", datasetDatasetExecuteQueriesRequest);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code give me error &lt;STRONG&gt;"Operation returned an invalid status code 'BadRequest'"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help what am I missing here?&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 05:02:22 GMT</pubDate>
    <dc:creator>Coder86</dc:creator>
    <dc:date>2023-10-11T05:02:22Z</dc:date>
    <item>
      <title>PowerBiClient executequeries giving 'BadRequest' response.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBiClient-executequeries-giving-BadRequest-response/m-p/3466183#M44842</link>
      <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Below is the sample code to generate token and getting datasets and groups using PowerBIClient API class.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AuthenticationResult? authenticationResult = null;&lt;BR /&gt;IEnumerable&amp;lt;string&amp;gt; scopes = new string[] { "&lt;A href="https://analysis.windows.net/powerbi/api/.default" target="_blank" rel="noopener"&gt;https://analysis.windows.net/powerbi/api/.default&lt;/A&gt;" };&lt;BR /&gt;var tenantSpecificUrl = "&lt;A href="https://login.microsoftonline.com/tenent_Id/oauth2/token" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/tenent_Id/oauth2/token&lt;/A&gt;";&lt;/P&gt;&lt;P&gt;PublicClientApplication clientApp = PublicClientApplicationBuilder.Create("appId").&lt;BR /&gt;WithAuthority(tenantSpecificUrl).WithClientId("clientId").Build();&lt;BR /&gt;var userAccounts = clientApp.GetAccountsAsync().Result;&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;if (userAccounts == null)&lt;BR /&gt;{&lt;BR /&gt;authenticationResult = clientApp.AcquireTokenSilent(scopes, userAccounts?.FirstOrDefault()).ExecuteAsync().Result;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;authenticationResult = clientApp.AcquireTokenByUsernamePassword(scopes, "username", "password").ExecuteAsync().Result;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (MsalUiRequiredException)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;return authenticationResult.AccessToken;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Get Dataset and Use Below Code to ExecuteQueries&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DatasetExecuteQueriesResponse datasetExecuteQueriesResponse =&lt;BR /&gt;client.Datasets.ExecuteQueriesInGroup(new Guid("xxxxx"),&lt;BR /&gt;"xxxxx", datasetDatasetExecuteQueriesRequest);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code give me error &lt;STRONG&gt;"Operation returned an invalid status code 'BadRequest'"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone help what am I missing here?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 05:02:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBiClient-executequeries-giving-BadRequest-response/m-p/3466183#M44842</guid>
      <dc:creator>Coder86</dc:creator>
      <dc:date>2023-10-11T05:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBiClient executerqueries giving 'BadRequest' response.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBiClient-executequeries-giving-BadRequest-response/m-p/3469991#M44871</link>
      <description>&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/628334"&gt;@Coder86&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Can you please share some more detail information about this issue? They should help us clarify your scenario and test to troubleshoot.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 00:46:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBiClient-executequeries-giving-BadRequest-response/m-p/3469991#M44871</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-11T00:46:48Z</dc:date>
    </item>
  </channel>
</rss>

