使用 powershell 在 vsts 中使用 rest api 创建工作项?

Create work items in vsts with rest api using powershell?

我正在尝试使用 power shell 在 VSTS 中创建一个工作项,我将在我的一些自定义解决方案中使用它

谁能帮我写脚本?

参考这个脚本:

param(
[string]$witType,
[string]$witTitle
)
$u="https://[account].visualstudio.com/DefaultCollection/[team project]/_apis/wit/workitems/`$$($witType)?api-version=1.0"
$body="[
  {
    `"op`": `"add`",
    `"path`": `"/fields/System.Title`",
    `"value`": `"$($witTitle)`"
  }
]"
$user = "test"
$token = "[personal access token]"

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$result=Invoke-RestMethod -Method PATCH -Uri $u -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json-patch+json" -Body $body

参数:-witType "task" -witTitle "PowerShellWIT1"