Sidehistorik
...
In the Latter, I have switched to this code (the Authentication in the above does not work very well - good stuff from here: http://poshcode.org/5471):
Kodeblok |
---|
# Connect parameters for JIRA REST $jirausername="user" $jirapassword="password" $jirarestapiuri = "https://jira.netic.dk/rest/api/2/" $bytes = [System.Text.Encoding]::UTF8.GetBytes("$jirausername`:$jirapassword") $global:encodedCredentials = [System.Convert]::ToBase64String($bytes) Try { $resturi="https://jira.server.dk/rest/api/2/issue/" + $jirakey $WebRequest = [System.Net.WebRequest]::Create($resturi) $WebRequest.Headers["Authorization"] = "Basic " + $global:encodedCredentials; $WebRequest.Method = "PUT" $WebRequest.ContentType = "application/json" $PostStr = [System.Text.Encoding]::UTF8.GetBytes($json) $WebRequest.ContentLength = $PostStr.Length $requestStream = $WebRequest.GetRequestStream() $requestStream.Write($PostStr, 0,$PostStr.length) $requestStream.Close() [System.Net.WebResponse] $resp = $WebRequest.GetResponse(); $rs = $resp.GetResponseStream(); [System.IO.StreamReader] $sr = New-Object System.IO.StreamReader -argumentList $rs; [string] $results = $sr.ReadToEnd(); $resp.Close() } Catch { $ErrorMessage = $_.Exception.Message $FailedItem = $_.Exception.ItemName Write-Host ($jirakey + ": " + $FailedItem + " - The error message was " + $ErrorMessage) } |
...