Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
rich_russell
New Member

REST API Dataflow refreshschedule fails to disable refresh

I need to turn off the scheduled refresh of a dataset, via Powershell.  I've successfully used the REST API to enable the refresh and set days/times, and the corresponding REST API works to disabled refresh on datasets.  The Invoke-RestMethod call below does not return an error or throw an exception, but it has no effect on the dataflow:

function DisableDataflowRefresh([String]$workspaceId,[String]$dataflowId{
    $UserAccessToken = Get-PowerBIAccessToken
    $bearer = $UserAccessToken.Authorization.ToString()

    $url = 'https://api.powerbi.com/v1.0/myorg/groups/'+$workspaceId+'/dataflows/'+$dataflowId+'/refreshSchedule'

    $headers = @{
            'Authorization' = $bearer
            'Content-Type' = 'application/json'
        }  
    $body = @{
        "value" =  @{                        
                        "enabled"="false"                  
                    }
    }
    $bodyjson = $body | ConvertTo-Json
   
    try {
        (Invoke-RestMethod -Method PATCH -Uri $Url -Headers $headers -Body $bodyjson)
    } catch {
        write-output ">>> REST API failed with error $($Error[0])"
    }
}
 
Thanks in advance!

 

2 REPLIES 2
rich_russell
New Member

Updating: I've worked past this, but for the life of me I don't know how.  That is, I re-wrote the function (using exactly the same approach) on the off chance that doing so would avoid a typo or something in the original function...and the new function works.  Old function still fails.  So I'm going to slink away, knowing I've got some stupid mistake and suspecting that resolving it would not really enlighten anyone else, anyway.

Not sure if it matters but was a refresh running at the time? Assume you didn't change dataset ownership either?

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.