Getting error. Can anyone help me ?
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
}
$restapiuri = "https://baseurl/rest/api/2/issue"
$headers = Get-HttpBasicHeader "user" "long string"
$body = @"
{
"fields": {
"project": {
"id": "14958"
},
"summary": "Test",
"description": "Test",
"issuetype": {
"id": "3"
},
"reporter": {
"name": "user mail"
}
}
}
"@
try {
$response = Invoke-RestMethod -Uri $restapiuri -Headers $headers -Method POST -ContentType "application/json" -Body $body
} catch {
Write-Host "Error: $($_.Exception.Message)"
if ($_.Exception.Response -ne $null) {
$errorResponse = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($errorResponse)
$errorDetails = $reader.ReadToEnd()
Write-Host "Error Details: $errorDetails"
}
}
Error: The remote server returned an error: (400) Bad Request.
Error Details: {"errorMessages":[],"errors":{"reporter":"Reporter is required."}}
as far as I know the reporter needs to be added with the user‘s id instead of name.
See a similar question in the link below:
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.