Я пытаюсь добавить задачу как дочернюю к истории в PowerShell. Но я продолжаю получать недействительный патч-документ. Получение двух рабочих элементов работает нормально, но я не могу обновить родительскую задачу.
$tfsToken = "MyPAT"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($tfsToken)"))
$defaultColletion = "DEFAULT_Collection"
$project = "MyProject"
$childID = "63573"
$parentID = "58342"
$childuri = ("http://tfs:8080/tfs/" + $defaultColletion + "/" + $project + "/_apis/wit/workitems?ids=" + $childID + "&expand=relations&api-version=5.0")
$parenturi = ("http://tfs:8080/tfs/" + $defaultColletion + "/" + $project + "/_apis/wit/workitems?ids=" + $parentID + "&expand=relations&api-version=5.0")
$header = @{authorization = "Basic $token"}
$childresult = Invoke-WebRequest -Uri $childuri -Method Get -Headers $header -ContentType "application/json-patch+json"
$parentresult = Invoke-WebRequest -Uri $parenturi -Method Get -Headers $header -ContentType "application/json-patch+json"
$childObj = $childresult.Content | ConvertFrom-Json
$parentObj = $parentresult.Content | ConvertFrom-Json
$jsonArr = @()
$link = @{}
$link.Add("rel","System.LinkTypes.Hierarchy-Forward")
$link.Add("url",$childObj.value.url)
$atts = @{}
$atts.Add("isLocked",$false)
$atts.Add("name","Child")
$link.Add("attributes",$atts)
$relations = @{}
$relations.add("path","/relations/-")
$relations.Add("op","add")
$relations.Add("value",$link)
$jsonArr += $relations
$body = $jsonArr | ConvertTo-Json
$resultUpdate = Invoke-WebRequest -Uri ($parentObj.value.url + "?api-version=5.0") -Method Patch -Headers $header -ContentType "application/json-patch+json" -Body $body