Create work items in vsts with rest api using powershell?

不想你离开。 提交于 2019-12-11 17:12:53

问题


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?


回答1:


Refer to this 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

Arguments: -witType "task" -witTitle "PowerShellWIT1"



来源:https://stackoverflow.com/questions/47433167/create-work-items-in-vsts-with-rest-api-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!