【问题标题】:Create work items in vsts with rest api using powershell?使用powershell在带有rest api的vst中创建工作项?
【发布时间】:2018-05-06 02:26:00
【问题描述】:

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

谁能帮我写剧本?

【问题讨论】:

  • 你尝试了什么,什么不起作用?请编辑问题,以便我们为您提供帮助

标签: powershell azure-devops azure-devops-rest-api


【解决方案1】:

参考这个脚本:

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"

【讨论】:

    猜你喜欢
    • 2017-07-20
    • 2020-07-26
    • 2021-03-19
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 2015-09-24
    • 2020-05-09
    相关资源
    最近更新 更多