<?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 Re: Rest API executeQueries Python in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2093024#M31979</link>
    <description>&lt;P&gt;HTTPError: 400 Client Error: Bad Request&amp;nbsp;means the request you made has error. And I think the server may check some headers in the HTTP reques.&lt;/P&gt;
&lt;P&gt;You could refer to this thread:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Get-Reports-REST-api-not-working-Showing-400-Bad-Request/m-p/450949" target="_self"&gt;https://community.powerbi.com/t5/Developer/Get-Reports-REST-api-not-working-Showing-400-Bad-Request/m-p/450949&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 05:38:50 GMT</pubDate>
    <dc:creator>V-lianl-msft</dc:creator>
    <dc:date>2021-09-23T05:38:50Z</dc:date>
    <item>
      <title>Rest API executeQueries Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2087614#M31912</link>
      <description>&lt;P&gt;Hello Developer Community,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Context:&lt;BR /&gt;Programming Language- Python&lt;BR /&gt;Enviroment -Azure Databricks&lt;BR /&gt;Authentication Type: 'acquire_token_with_client_credentials'&lt;BR /&gt;&lt;BR /&gt;Problem Statement:&lt;BR /&gt;While using the 'executeQueries' rest api call, i receive a '&lt;SPAN&gt;&lt;EM&gt;400 Client Error: Bad Request for url&lt;/EM&gt;'. My code is as follows:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;post_query = 'https://api.powerbi.com/v1.0/myorg/datasets/&amp;lt;dataset-id&amp;gt;/executeQueries'
header = {'Authorization': f'Bearer {access_token}','Content-Type' : 'application/json'}
body = {
  "queries": [
    {
      "query": "EVALUATE VALUES(Merge1[Email])"
}
  ],
  "serializerSettings": {
    "includeNulls": "true"
  }
}

post_r = requests.post(url=post_query,data=body, headers=header)
post_r.raise_for_status()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Additional Context:&lt;BR /&gt;Alterantive Trial-1: I've tried using&amp;nbsp; the following, but was not sucessful.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;post_r = requests.post(url=post_query,json= json.dumps(body), headers=header)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alternative Trial-2: I tried the same dataset and body using the Microsoft documentation 'Try it' option(&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries#code-try-0" target="_self"&gt;&lt;U&gt;&lt;EM&gt;https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries#code-try-0&lt;/EM&gt;&lt;/U&gt;&lt;/A&gt;) and was succesful in receving the following:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rest_api_error.png.jpg" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/597311i699C3F9D284F70D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rest_api_error.png.jpg" alt="Rest_api_error.png.jpg" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would really appreciate any response which would help me get closer to the solution.&lt;BR /&gt;Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 14:21:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2087614#M31912</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-21T14:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API executeQueries Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2093024#M31979</link>
      <description>&lt;P&gt;HTTPError: 400 Client Error: Bad Request&amp;nbsp;means the request you made has error. And I think the server may check some headers in the HTTP reques.&lt;/P&gt;
&lt;P&gt;You could refer to this thread:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Developer/Get-Reports-REST-api-not-working-Showing-400-Bad-Request/m-p/450949" target="_self"&gt;https://community.powerbi.com/t5/Developer/Get-Reports-REST-api-not-working-Showing-400-Bad-Request/m-p/450949&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 05:38:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2093024#M31979</guid>
      <dc:creator>V-lianl-msft</dc:creator>
      <dc:date>2021-09-23T05:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API executeQueries Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2094777#M32003</link>
      <description>&lt;P&gt;Thank you for the reply. But i think i solved the issue by passing the body as a string value.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;body = '''{
  "queries": [
    {
      "query": "EVALUATE VALUES(Merge1[Email])"
}
  ],
  "serializerSettings": {
    "includeNulls": "true"
  }
}'''&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 14:51:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/2094777#M32003</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-23T14:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rest API executeQueries Python</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/3161652#M41996</link>
      <description>&lt;P&gt;Hi, I had similar issue and your solution fixed the 400 error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now i am getting 401 error below:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;lt;Response [401]&amp;gt; {"error":{"code":"PowerBINotAuthorizedException","pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}}} JSON Response {'error': {'code': 'PowerBINotAuthorizedException', 'pbi.error': {'code': 'PowerBINotAuthorizedException', 'parameters': {}, 'details': [], 'exceptionCulprit': 1}}}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Here's my code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;body = '''{&lt;BR /&gt;"queries": [&lt;BR /&gt;{&lt;BR /&gt;"query": "EVALUATE VALUES(BENEFIT_PLAN[LAST_UPDATE_DATE])"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}'''&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;api_call = requests.post(url=datasets_rowcount_url,data=body, headers=header)&lt;BR /&gt;query_json=api_call.text.encode().decode('utf-8-sig')&lt;BR /&gt;print(query_json)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 18:44:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Rest-API-executeQueries-Python/m-p/3161652#M41996</guid>
      <dc:creator>mshilendhari</dc:creator>
      <dc:date>2023-03-29T18:44:25Z</dc:date>
    </item>
  </channel>
</rss>

