<?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 Power BI REST API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1948339#M30429</link>
    <description>&lt;P&gt;Hi everyone , I'm trying to get all the datasources for my organization.I'm using a service principal to connect to Power BI Service.&lt;BR /&gt;I made a function with PowerShell where I have made a this loop to get all the datasetId.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;$OrgWorkspaces = Get-PowerBIDataset -Scope Organization&lt;BR /&gt;foreach ( $OrgWorkspace in $OrgWorkspaces)&lt;BR /&gt;{&lt;BR /&gt;$DatasetId= $($&lt;A href="http://orgworkspace.id/" target="_blank" rel="noopener"&gt;OrgWorkspace.Id&lt;/A&gt;)&lt;BR /&gt;# Write-Host $DatasetId&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;And this worked But when I added this line of code&lt;BR /&gt;&lt;STRONG&gt;$DataSources = Get-PowerBIDatasource -DatasetId $DatasetId&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;into the loop It didn't work ! I tried to put a DatasetId from the list I had&lt;BR /&gt;&lt;/EM&gt;&lt;EM&gt;$DataSources = Get-PowerBIDatasource -DatasetId 1505150a-36f2-408e-a1e7-3531e6e0fccf&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;*** but I have this error:&lt;BR /&gt;[Error] ERROR: Operation returned an invalid status code 'Forbidden'Exception :Type : Microsoft.Rest.HttpOperationExceptionRequest :Method : GETRequestUri :&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://api.powerbi.com/v1.0/myorg/datasets/1505150a-36f2-408e-a1e7-3531e6e0fccf/datasourcesHeaders" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/datasets/1505150a-36f2-408e-a1e7-3531e6e0fccf/datasourcesHeaders&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;:Authorization : …User-Agent : MicrosoftPowerBIMgmt/1.2.0.0Response :StatusCode : ForbiddenReasonPhrase : ForbiddenContent : {"Message":"API is not accessible for application".&lt;/P&gt;&lt;P&gt;Any idea of this error please?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 14:02:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-09T14:02:24Z</dc:date>
    <item>
      <title>Power BI REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1948339#M30429</link>
      <description>&lt;P&gt;Hi everyone , I'm trying to get all the datasources for my organization.I'm using a service principal to connect to Power BI Service.&lt;BR /&gt;I made a function with PowerShell where I have made a this loop to get all the datasetId.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;$OrgWorkspaces = Get-PowerBIDataset -Scope Organization&lt;BR /&gt;foreach ( $OrgWorkspace in $OrgWorkspaces)&lt;BR /&gt;{&lt;BR /&gt;$DatasetId= $($&lt;A href="http://orgworkspace.id/" target="_blank" rel="noopener"&gt;OrgWorkspace.Id&lt;/A&gt;)&lt;BR /&gt;# Write-Host $DatasetId&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;And this worked But when I added this line of code&lt;BR /&gt;&lt;STRONG&gt;$DataSources = Get-PowerBIDatasource -DatasetId $DatasetId&lt;/STRONG&gt;&lt;EM&gt;&lt;BR /&gt;into the loop It didn't work ! I tried to put a DatasetId from the list I had&lt;BR /&gt;&lt;/EM&gt;&lt;EM&gt;$DataSources = Get-PowerBIDatasource -DatasetId 1505150a-36f2-408e-a1e7-3531e6e0fccf&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;*** but I have this error:&lt;BR /&gt;[Error] ERROR: Operation returned an invalid status code 'Forbidden'Exception :Type : Microsoft.Rest.HttpOperationExceptionRequest :Method : GETRequestUri :&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://api.powerbi.com/v1.0/myorg/datasets/1505150a-36f2-408e-a1e7-3531e6e0fccf/datasourcesHeaders" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/datasets/1505150a-36f2-408e-a1e7-3531e6e0fccf/datasourcesHeaders&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;:Authorization : …User-Agent : MicrosoftPowerBIMgmt/1.2.0.0Response :StatusCode : ForbiddenReasonPhrase : ForbiddenContent : {"Message":"API is not accessible for application".&lt;/P&gt;&lt;P&gt;Any idea of this error please?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 14:02:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1948339#M30429</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-09T14:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1951524#M30465</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to the error message, it seems that you do not have the appropriate permission to view the data source information of this data set. Please confirm whether to &lt;STRONG&gt;&lt;A href="https://docs.microsoft.com/en-us/power-bi/admin/read-only-apis-service-principal-authentication" target="_self"&gt;Enable service principal authentication for read-only admin APIs&lt;/A&gt;&lt;/STRONG&gt; and check whether to add the service principal as a member or admin to your workspace. Change your cmdlet scripts as below and check whether it can work well, you can refer the content in this blog:&amp;nbsp;&lt;A style="background-color: #ffffff; outline: 0px;" href="https://insightsquest.com/2019/04/17/power-bi-admin-datasets/" target="_self"&gt;&lt;STRONG&gt;POWER BI ADMIN DATASETS&lt;/STRONG&gt;&lt;/A&gt; .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Please make sure the dataset id is correct.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;$DataSources = Get-PowerBIDatasource -DatasetId 1505150a-36f2-408e-a1e7-3531e6e0fccf ***&amp;nbsp;&lt;FONT color="#FF0000"&gt; -Scope Organization&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;In addition, please review the following rest API and check whether it can get your desired result.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasources-as-admin" target="_self"&gt;&lt;STRONG&gt;Admin - Datasets GetDatasourcesAsAdmin&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 08:24:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1951524#M30465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-12T08:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1970481#M30629</link>
      <description>&lt;P&gt;Thank you for your answer!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 12:35:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Power-BI-REST-API/m-p/1970481#M30629</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-21T12:35:22Z</dc:date>
    </item>
  </channel>
</rss>

