You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.