使用PowerShell在带有REST API的VSTS中创建工作项? [英] Create work items in vsts with rest api using powershell?

查看:85
本文介绍了使用PowerShell在带有REST API的VSTS中创建工作项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Power Shell在VSTS中创建一个工作项,我将在一些自定义解决方案中使用该工作项

I am trying to create a work-item in VSTS using power shell that I will be using with some of my custom solutions

有人可以帮我编写脚本吗?

Can anyone help me with the script?

推荐答案

请参阅以下脚本:

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"

这篇关于使用PowerShell在带有REST API的VSTS中创建工作项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆