<?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: Dataset refresh REST API, Service Principal Not Authorised in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2616863#M37168</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;As the document mentions, this refresh API required an additional option 'notifyOption' in the body. I'd like to suggest you add it to your request and try again:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refresh-dataset-in-group#request-body" target="_blank"&gt;Datasets - Refresh Dataset In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;BTW, what type of data source are you working on? If you mean Azure Analysis Services, it seems to need additional permission for that instance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jul 2022 09:19:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-07-04T09:19:14Z</dc:date>
    <item>
      <title>Dataset refresh REST API, Service Principal Not Authorised</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2614046#M37130</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to trigger a refresh via the Rest API using a service principle registered app. So far, the app has been granted all PowerBi permissions in Azure, it is also part of a a security group with all PowerBi permissions, and I have granted API access for service principals in the admin portel. Futhermore, the service principle has admin access in the workspace of the dataset in question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When making the REST API request, I successfully aquire an access token with the service principle client info:&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;import requests

url = 'https://login.microsoftonline.com/common/oauth2/token'
data = {
        'grant_type':  'client_credentials',
        'scope': 'https://api.powerbi.com',
        'resource': 'https://analysis.windows.net/powerbi/api',
        'client_id': &amp;lt;Client ID&amp;gt;,
        
        'client_secret': &amp;lt;Client Secret&amp;gt;
        }
r = requests.post(url, data=data)
access_token = r.json().get('access_token')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I make the request using this token, I get a response error 401, not authorised:&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;header = {'Authorization': f'Bearer {access_token}'}

url='https://api.powerbi.com/v1.0/myorg/groups/' + &amp;lt;Group ID&amp;gt; + '/datasets/' + &amp;lt;Dataset ID&amp;gt; + '/refreshes'
r = requests.post(url=url, headers=header)
print(r.status_code)&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;I can only imagine it's some authorisation issue external to the request. Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 10:52:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2614046#M37130</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-01T10:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset refresh REST API, Service Principal Not Authorised</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2616863#M37168</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;As the document mentions, this refresh API required an additional option 'notifyOption' in the body. I'd like to suggest you add it to your request and try again:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refresh-dataset-in-group#request-body" target="_blank"&gt;Datasets - Refresh Dataset In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;BTW, what type of data source are you working on? If you mean Azure Analysis Services, it seems to need additional permission for that instance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 09:19:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2616863#M37168</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-07-04T09:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset refresh REST API, Service Principal Not Authorised</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2617061#M37173</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I think you need to add the SPN as admin in the Workspace where your dataset is stored. The best way to do this is, if you havent already done this, is to put the SPN in a Security Group in AAD. Then grant this security group admin access to the workspace. After you have granted access it can take a while before the access has been granted, so I suggest to wait 30 min before trying the REST API again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Br&lt;BR /&gt;Marius&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2022 10:00:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Dataset-refresh-REST-API-Service-Principal-Not-Authorised/m-p/2617061#M37173</guid>
      <dc:creator>mariussve1</dc:creator>
      <dc:date>2022-07-04T10:00:13Z</dc:date>
    </item>
  </channel>
</rss>

