使用Powershell通过JIRA REST API更改受让人并向问题添加注释

使用Powershell通过JIRA REST API更改受让人并向问题添加注释,api,rest,powershell,curl,jira,Api,Rest,Powershell,Curl,Jira,对于如此简单的事情,我没有幸通过RESTAPI更新JIRA问题 是否有人能够使用Powershell更新JIRA问题?我已经用尽了stackoverflow和atlassian网站上的所有选项 curl、invoke restmethod或invoke webrequest的脚本只返回了错误 从问题中检索信息不是问题。改变它。。。天哪 如果有人能帮我找到解决这个问题的方法,我将不胜感激 谢谢 使用调用RestMethod。你用的是什么命令?错误是什么?谢谢你的回复,皇家空军。将凭证转换为b64后

对于如此简单的事情,我没有幸通过RESTAPI更新JIRA问题

是否有人能够使用Powershell更新JIRA问题?我已经用尽了stackoverflow和atlassian网站上的所有选项

curl、invoke restmethod或invoke webrequest的脚本只返回了错误

从问题中检索信息不是问题。改变它。。。天哪

如果有人能帮我找到解决这个问题的方法,我将不胜感激


谢谢

使用
调用RestMethod
。你用的是什么命令?错误是什么?谢谢你的回复,皇家空军。将凭证转换为b64后,我定义了特定的票证:$uri=”“$headers=Get-HttpBasicHeader$credentials Invoke RestMethod-uri$uri-method-Get-headers$headers-ContentType“application/json”。错误是什么?Välkommen直到StackOverflow。你愿意贡献自己的力量真是太好了。但是,如果您对代码进行注释并解释相关部分,而不是仅仅粘贴一些代码,则会更好。这将有助于询问者以及任何未来的读者理解。
function ConvertTo-Base64($string) {
    $bytes  = [System.Text.Encoding]::UTF8.GetBytes($string);
    $encoded = [System.Convert]::ToBase64String($bytes);
    return $encoded;
}

function Get-HttpBasicHeader([string]$username, [string]$password, $Headers = @{}) {
    $b64 = ConvertTo-Base64 "$($username):$($Password)"
    $Headers["Authorization"] = "Basic $b64"
    $Headers["X-Atlassian-Token"] = "nocheck"
    return $Headers
}

function add_comment([string]$issueKey,[string]$comment) {
    $body = ('{"body": "'+$comment+'"}')
    $comment=(Invoke-RestMethod -uri ($restapiuri +"issue/$issueKey/comment") -Headers $headers -Method POST -ContentType "application/json" -Body $body).id    
    return $comment
}


$restapiuri = "https://jira.server.com/rest/api/2/"
$headers = Get-HttpBasicHeader "user" "password"

add_comment "MyIssue-1234" "[~test.user] please handle the issue."