使用 invoke-restmethod 在现有 JIRA 票证中添加 sprint 值

问题描述 投票:0回答:1

我想通过 Powershell 在现有 JIRA 票证中添加 sprint 值(或名称、字符串或 id),更具体地说,是调用 Restmethod(不使用curl)。

有人可以给我提到一个现有的链接或给我一个例子吗?

powershell jira jira-rest-api invoke-restmethod
1个回答
0
投票

根据可用的在线文档,您似乎需要向

/rest/agile/1.0/sprint/{sprintId}/issue
发送POST请求:

$jiraHostName = "https://<jira host name goes here>"
$targetSprintId = 123                     # replace with actual sprint identifier
$oauthBearerToken = "<token goes here>"   # see https://confluence.atlassian.com/adminjiraserver/jira-oauth-2-0-provider-api-1115659070.html
$issuesToUpdate = @(                      # replace with actual issue identifiers
  'PROJ-123',
  'PROJ-456'
)

$irmArgs = @{
  Uri = "${jiraHostName}/rest/agile/1.0/sprint/${targetSprintId}/issue"
  Headers = @{
    'Authorization' = "Bearer $oauthBearerToken"
    'X-Atlassian-Token' = 'nocheck'
  }
  Method = Post
  Body = @{
    'issues' = $issuesToUpdate
  }
  ContentType = 'application/json'
}

Invoke-RestMethod @irmArgs
© www.soinside.com 2019 - 2024. All rights reserved.