0
votes

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
what have you tried, what doesnt work? please edit the question so we can help you4c74356b41

1 Answers

3
votes

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"