通过 REST 将任务作为子任务添加到故事中 API
Adding a task as child to a story by REST API
我正在尝试将任务作为子任务添加到 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
我正在尝试将任务作为子任务添加到 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