qiita.com
powershell -ExecutionPolicy RemoteSigned-command .\redmine_issue.ps1 `
-accessKey xxxx `
-redmineUrl http://xxxxx.com `
-projectID XX `
-trackerID XX `
-title "XXX" `
-desc "XXX" `
-userId X `
-watcherIdArray X,Y,Z
Param(
[String]$accessKey,
[String]$redmineUrl,
[String]$projectID,
[String]$trackerID,
[String]$title,
[String]$desc,
[String]$userId,
[array]$watcherIdArray,
)
$postUri = $redmineUrl + "/issues.json"
$issue = @{
project_id = $projectID;
tracker_id = $trackerID;
subject = $title;
description = $desc.Replace("\r\n","`n") # 説明
assigned_to_id = $userId; # 担当者 ユーザID or グループID
watcher_user_ids = $watcherIdArray;
}
$issueJson = @{issue = $issue; key = $accessKey}
# 書き換えたパラメータをjson形式に戻す
$postText = ConvertTo-Json $issueJson
#body部(json)変換
$postBody = [Text.Encoding]::UTF8.GetBytes($postText)
#REST API実行
$Redmine = Invoke-RestMethod -Method POST -Uri $postUri -Body $postBody -ContentType application/json