Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Create JIRA Issue with REST API via PowerShell

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."}}

1 answer

1 accepted

2 votes
Answer accepted
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 12, 2023

Hi @Ashiquer Rahman Bhuiya 

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:

https://community.atlassian.com/t5/Jira-questions/How-to-set-reporter-on-an-issue-created-via-Jira-Rest-API/qaq-p/2188822

Best
Stefan

Hi @Stefan Salzl Thanks a lot. It works :)

Like Stefan Salzl likes this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 13, 2023

Hi @Ashiquer Rahman Bhuiya 

Awesome. Good to know you got that working 💪💪

Best
Stefan

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events