<?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: Problems using Invoke-PowerBiRestMethod in PowerShell in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Problems-using-Invoke-PowerBiRestMethod-in-PowerShell/m-p/2841424#M39249</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/310471"&gt;@g_m_j&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your statement, I think 404 error should be an authentication error in Power BI. Please make sure your account has access to Power BI or have access to pass the refresh API to Power BI.&lt;/P&gt;
&lt;P&gt;About using Powershell to refresh dataset, I think this blog could help you better to use it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.fourmoo.com/2018/06/05/using-the-power-bi-api-with-powershell-scripts-refreshing-your-dataset/" target="_self" rel="nofollow noopener noreferrer"&gt;Using-the-power-bi-api-with-powershell-scripts-refreshing-your-dataset&lt;/A&gt;&amp;nbsp;&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>Fri, 14 Oct 2022 06:04:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-14T06:04:49Z</dc:date>
    <item>
      <title>Problems using Invoke-PowerBiRestMethod in PowerShell</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problems-using-Invoke-PowerBiRestMethod-in-PowerShell/m-p/2839770#M39242</link>
      <description>&lt;P&gt;(I'm no PowerShell expert)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to script PowerBI dataset refreshes using a PowerShell script and the &lt;STRONG&gt;Invoke-PowerBIRestMethod&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It all works fine for a single hardcoded dataset, as below:&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;$body = "{'notifyOption':'MailOnCompletion'}"
$result = Invoke-PowerBIRestMethod -url "https://api.powerbi.com/v1.0/myorg/datasets/xxxxxxxxxxxxxxxxxxxxxxxxxx/refreshes" -Method POST -Body $body&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'd like to store all my dataset IDs in a txt file, then pass these in as a variable and get the script to loop through each. This is where I'm hitting (unhelpful) errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script is as below:&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;Login-PowerBI

$body = "{'notifyOption':'MailOnCompletion'}"
$Data=Import-Csv -Path "\\abc\Desktop\PBI_Dashboards_Refresh_List.txt" -Delimiter ","

foreach ($dat in $Data)

{
$result = Invoke-PowerBIRestMethod -url "https://api.powerbi.com/v1.0/myorg/datasets/$dat.WorkspaceID/refreshes" -Method POST -Body $body

}
Resolve-PowerBIError -Last&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I'm getting is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;Message : Response status code does not indicate success: 404 (Not Found).
StackTrace : at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.&amp;lt;InvokeRestMethod&amp;gt;d__35.MoveNext()
Exception : System.Net.Http.HttpRequestException
InvocationInfo : {Invoke-PowerBIRestMethod}
Line : $result = Invoke-PowerBIRestMethod -url "https://api.powerbi.com/v1.0/myorg/datasets/$dat.WorkspaceID/refreshes" -Method POST -Body $body

Position : At line:7 char:15
+ ... $result = Invoke-PowerBIRestMethod -url "https://api.powerbi.com/v1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 25&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 13:27:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problems-using-Invoke-PowerBiRestMethod-in-PowerShell/m-p/2839770#M39242</guid>
      <dc:creator>g_m_j</dc:creator>
      <dc:date>2022-10-13T13:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using Invoke-PowerBiRestMethod in PowerShell</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Problems-using-Invoke-PowerBiRestMethod-in-PowerShell/m-p/2841424#M39249</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/310471"&gt;@g_m_j&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your statement, I think 404 error should be an authentication error in Power BI. Please make sure your account has access to Power BI or have access to pass the refresh API to Power BI.&lt;/P&gt;
&lt;P&gt;About using Powershell to refresh dataset, I think this blog could help you better to use it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.fourmoo.com/2018/06/05/using-the-power-bi-api-with-powershell-scripts-refreshing-your-dataset/" target="_self" rel="nofollow noopener noreferrer"&gt;Using-the-power-bi-api-with-powershell-scripts-refreshing-your-dataset&lt;/A&gt;&amp;nbsp;&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>Fri, 14 Oct 2022 06:04:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Problems-using-Invoke-PowerBiRestMethod-in-PowerShell/m-p/2841424#M39249</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-14T06:04:49Z</dc:date>
    </item>
  </channel>
</rss>

