<?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 404 Error with Invoke-PowerBIRestmethod, Get Refresh History In Group in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/404-Error-with-Invoke-PowerBIRestmethod-Get-Refresh-History-In/m-p/2337557#M34396</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to do some basIc scripting to regularly pull my PBI refresh history as part of a bigger set of usage metric tracking, using Azure function apps. All my functions log in to PBI with a service principal that has delegated Tenant.ReadWriteAll permissions, like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$applicationId = "bbd694ab-1da9-426f-97ab-896661bc32a7"

$securePassword = "[redacted]" | ConvertTo-SecureString -AsPlainText -Force

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword

Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "93fb7985-8893-49e5-8440-bb350d28a54f"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine for most things, including most API URLs for Invoke-PowerBIRestMethod, but when I try to use Invoke... with the Get Refresh History In Group call I get a 404 error. This *only* happens when I'm accessing the API as the service principal; if I make the API call in Postman using an Authorization header it works fine. My query is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$url = "https://api.powerbi.com/v1.0/myorg/groups/f1f6f5db-02b3-4650-a4aa-fc93171aede9/datasets/173489c2-285c-484d-ac0d-7e382eec87ce/refreshes"

invoke-powerbirestmethod -Url $url -method Get &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 404s like this on every non-admin API call; the admin versions all work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty new to working with Powershell and the world of Azure so this is probably something pretty obvious, but it's eating my lunch.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 17:20:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-02-14T17:20:08Z</dc:date>
    <item>
      <title>404 Error with Invoke-PowerBIRestmethod, Get Refresh History In Group</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/404-Error-with-Invoke-PowerBIRestmethod-Get-Refresh-History-In/m-p/2337557#M34396</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to do some basIc scripting to regularly pull my PBI refresh history as part of a bigger set of usage metric tracking, using Azure function apps. All my functions log in to PBI with a service principal that has delegated Tenant.ReadWriteAll permissions, like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$applicationId = "bbd694ab-1da9-426f-97ab-896661bc32a7"

$securePassword = "[redacted]" | ConvertTo-SecureString -AsPlainText -Force

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword

Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "93fb7985-8893-49e5-8440-bb350d28a54f"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine for most things, including most API URLs for Invoke-PowerBIRestMethod, but when I try to use Invoke... with the Get Refresh History In Group call I get a 404 error. This *only* happens when I'm accessing the API as the service principal; if I make the API call in Postman using an Authorization header it works fine. My query is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$url = "https://api.powerbi.com/v1.0/myorg/groups/f1f6f5db-02b3-4650-a4aa-fc93171aede9/datasets/173489c2-285c-484d-ac0d-7e382eec87ce/refreshes"

invoke-powerbirestmethod -Url $url -method Get &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 404s like this on every non-admin API call; the admin versions all work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty new to working with Powershell and the world of Azure so this is probably something pretty obvious, but it's eating my lunch.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:20:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/404-Error-with-Invoke-PowerBIRestmethod-Get-Refresh-History-In/m-p/2337557#M34396</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-02-14T17:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: 404 Error with Invoke-PowerBIRestmethod, Get Refresh History In Group</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/404-Error-with-Invoke-PowerBIRestmethod-Get-Refresh-History-In/m-p/2344188#M34452</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have check Power BI REST API &lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/datasets" target="_self"&gt;offical blog&lt;/A&gt; and I think&amp;nbsp;&lt;SPAN&gt;Get Refresh History In Group API should support&amp;nbsp;Service Principal.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If 404 error only appears&amp;nbsp;when you choose Service Principal for authentication, please check whether you configure&amp;nbsp;Service Principal correctly. You should give security group which has added Service Principal as a member the API permission from Admin portal in Power BI Service and add&amp;nbsp;Service Principal as a member in Power BI Workspace.&lt;/P&gt;
&lt;P&gt;For reference:&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal" target="_self"&gt;Embed Power BI content with service principal and an application secret&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 08:22:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/404-Error-with-Invoke-PowerBIRestmethod-Get-Refresh-History-In/m-p/2344188#M34452</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-02-17T08:22:01Z</dc:date>
    </item>
  </channel>
</rss>

