JIRA REST API (バージョン = 5.2-m06-4) と対話しようとしています。
次のようなコードがあります。
function ConvertTo-Base64($string) {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);
$encoded = [System.Convert]::ToBase64String($bytes);
return $encoded;
}
$reqBody = [System.Text.Encoding]::UTF8.GetBytes($data)
try{
$authenticationDetails = ConvertTo-Base64 '$username:$password'
Write-Host('Opening a connection to {0}' -f $url)
$req = [System.Net.WebRequest]::Create($Url)
$req.Headers.Add("AUTHORIZATION", $headerValue);
$req.Method = "POST"
$req.ContentType = "application/json"
$req.Timeout = $Timeout.TotalMilliseconds
$req.Credentials = New-Object System.Net.NetworkCredential -ArgumentList $username, $password
$req.PreAuthenticate = $true
$req.ContentLength = $reqBody.Length
$reqStream = $req.GetRequestStream()
$reqStream.Write($reqBody, 0, $reqBody.Length)
$reqStream.Close()
Write-Host($data)
$resp = $req.GetResponse()
Write-Verbose $resp
Write-Output $resp.StatusCode
}
catch [System.Net.WebException]{
if ($_.Exception -ne $null -and $_.Exception.Response -ne $null) {
$errorResult = $_.Exception.Response.GetResponseStream()
$errorText = (New-Object System.IO.StreamReader($errorResult)).ReadToEnd()
Write-Warning "The remote server response: $errorText"
Write-Output $_.Exception.Response.StatusCode
Write-Host $_
} else {
throw $_
}
}
コードは次のように JSON で渡されます。
$jsonString = '{"fields": {"project":{ "key": "CCB"},"components": "' + $COMPONENT + '"},"customfield_11502" : "' + $DEPLOYMENT_DATE + '" ,"Summary": "' + $description + '","issuetype": {"name": "Configuration Change"}}}'
私が抱えている問題は、この方法でデータを POST しようとすると、概要、customfield_11502、およびコンポーネントが画面の一部ではないと言われることです。JSON のこれらのプロパティを削除しようとすると、問題を投稿する権限がないと言われます。
ここでの正しいエラー メッセージは何ですか? 私が許可されていないということですか? もしそうなら、画面に表示されないフィールドは実際には問題ではありませんか?
ユーザー名とパスワードを REST API 経由で渡すときは、Base64 でエンコードし、ヘッダーでも渡します。私が見逃している明らかなものはありますか?