Create work items in vsts with rest api using powershell?

前端 未结 1 1565
死守一世寂寞
死守一世寂寞 2021-01-26 06:17

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条回答
  • 2021-01-26 07:13

    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"

    0 讨论(0)
提交回复
热议问题