How to disable a workflow task in a release using rest APIs?

Recently one of the customer wanted to know how to disable a task in a release using the rest APIs and here is the code that I shared with him. You can get the PAT token using the instructions mentioned here.

param (
[string] $token

## Construct a basic auth head using PAT
function BasicAuthHeader()

$ba = (“:{0}” -f $authtoken)
$ba = [System.Text.Encoding]::UTF8.GetBytes($ba)
$ba = [System.Convert]::ToBase64String($ba)
$h = @{Authorization=(“Basic{0}” -f $ba);ContentType=”application/json”}
return $h
$getReleaseUri = “”

$h = BasicAuthHeader $token

$release = Invoke-RestMethod -Uri $getReleaseUri -Headers $h -Method Get

# Disable a task in an environment
$release.environments[0].deployPhasesSnapshot[0].workflowTasks[0].enabled = $false;

####****************** update the modified object **************************
$release2 = $release | ConvertTo-Json -Depth 100
$release2 = [Text.Encoding]::UTF8.GetBytes($release2)

$updateReleaseUri = “`?api-version=4.0-preview.4”
$content2 = Invoke-RestMethod -Uri $updateReleaseUri -Method Put -Headers $h -ContentType “application/json” -Body $release2 -Verbose -Debug

write-host “==========================================================”

Comments (0)

Skip to main content