<?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: Update Dataflow Refresh Schedule with API using PowerShell in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Update-Dataflow-Refresh-Schedule-with-API-using-PowerShell/m-p/2592394#M36870</link>
    <description>&lt;P&gt;Just in case anyone else happens upon this and is having the same issue, I have found the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was missing the content-type in the header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$headers = @{&lt;BR /&gt;'Authorization' = "$bearer"&lt;BR /&gt;'Content-Type' = "application/json"&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2022 13:43:06 GMT</pubDate>
    <dc:creator>jhcannon</dc:creator>
    <dc:date>2022-06-21T13:43:06Z</dc:date>
    <item>
      <title>Update Dataflow Refresh Schedule with API using PowerShell</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Update-Dataflow-Refresh-Schedule-with-API-using-PowerShell/m-p/2590502#M36852</link>
      <description>&lt;P&gt;I am copying a complete workspace to another using PowerShell.&amp;nbsp; I've pieced together several scripts I found and filled in where I was missing things.&amp;nbsp; All that is working as I expect.&amp;nbsp; Now, I need to change a few things on the new dataflows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First - I need to change the data gateway that it uses.&amp;nbsp; I have parameters in my dataflows for the server and database names.&amp;nbsp; Updated those in the script but it also needs the gateway set and I cannot find a way to do that with APIs.&amp;nbsp; Maybe I'm missing that - if so please point me in right direction.&amp;nbsp; Right now, I have my script pause so I can set manually and then proceed.&amp;nbsp; Not ideal, but it serves the purpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I would like to add the refresh schedules to my dataflows.&amp;nbsp; I have tried the refeshSchedule (&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/dataflows/update-refresh-schedule" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/rest/api/power-bi/dataflows/update-refresh-schedule&lt;/A&gt;) but am getting errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my script :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$urir = [string]::Format("&lt;A href="https://api.powerbi.com/v1.0/myorg/groups/{0}/dataflows/{1}/refreshSchedule" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/groups/{0}/dataflows/{1}/refreshSchedule&lt;/A&gt;", $destinationWorkspace.Id, $dfInfo.objectId);&lt;/P&gt;&lt;P&gt;$ApiRequestBody = @"&lt;BR /&gt;{&lt;BR /&gt;"value": {&lt;BR /&gt;"days": [&lt;BR /&gt;"Sunday",&lt;BR /&gt;"Monday",&lt;BR /&gt;"Tuesday",&lt;BR /&gt;"Wednesday",&lt;BR /&gt;"Thursday",&lt;BR /&gt;"Friday",&lt;BR /&gt;"Saturday"&lt;BR /&gt;],&lt;BR /&gt;"times": [&lt;BR /&gt;"12:00"&lt;BR /&gt;],&lt;BR /&gt;"notifyOption": "NoNotification",&lt;BR /&gt;"localTimeZoneId": "035",&lt;BR /&gt;"enabled": true&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;"@&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Write-Host -ForegroundColor White ( [string]::Format("Request Body '{0}'", $ApiRequestBody ) );&lt;/P&gt;&lt;P&gt;Invoke-RestMethod -Uri $urir -Method PATCH -Body $ApiRequestBody;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the output from my script :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request Body ' {&lt;BR /&gt;"value": {&lt;BR /&gt;"days": [&lt;BR /&gt;"Sunday",&lt;BR /&gt;"Monday",&lt;BR /&gt;"Tuesday",&lt;BR /&gt;"Wednesday",&lt;BR /&gt;"Thursday",&lt;BR /&gt;"Friday",&lt;BR /&gt;"Saturday"&lt;BR /&gt;],&lt;BR /&gt;"times": [&lt;BR /&gt;"12:00"&lt;BR /&gt;],&lt;BR /&gt;"notifyOption": "NoNotification",&lt;BR /&gt;"localTimeZoneId": "035",&lt;BR /&gt;"enabled": true&lt;BR /&gt;}&lt;BR /&gt;}'&lt;BR /&gt;Invoke-RestMethod : The remote server returned an error: (415) Unsupported Media Type.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;+ Invoke-RestMethod -Uri $urir -Method PATCH -Headers $headers -Body $ApiRequestBody;&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc&lt;/P&gt;&lt;P&gt;eption&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried ConvertTo-Json / ConvertFrom-Json - same error message.&amp;nbsp; I know my ids in the variables are correct.&amp;nbsp; I've used same ones to do a single refresh and those work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My gut is it has something to do with the PATCH method but I do not know where to even start on that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 21:24:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Update-Dataflow-Refresh-Schedule-with-API-using-PowerShell/m-p/2590502#M36852</guid>
      <dc:creator>jhcannon</dc:creator>
      <dc:date>2022-06-20T21:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Update Dataflow Refresh Schedule with API using PowerShell</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Update-Dataflow-Refresh-Schedule-with-API-using-PowerShell/m-p/2592394#M36870</link>
      <description>&lt;P&gt;Just in case anyone else happens upon this and is having the same issue, I have found the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was missing the content-type in the header.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$headers = @{&lt;BR /&gt;'Authorization' = "$bearer"&lt;BR /&gt;'Content-Type' = "application/json"&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 13:43:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Update-Dataflow-Refresh-Schedule-with-API-using-PowerShell/m-p/2592394#M36870</guid>
      <dc:creator>jhcannon</dc:creator>
      <dc:date>2022-06-21T13:43:06Z</dc:date>
    </item>
  </channel>
</rss>

