Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,648
Community Members
 
Community Events
165
Community Groups

Creating issue in jira using rest API via powershell

Edited

function ConvertTo-Base64($string) {

$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);
$encoded = [System.Convert]::ToBase64String($bytes);
return $encoded;

}

$username = "***********"
$password = "***********"

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://jira.<Organization>.mhc/rest/api/2/issue"
$headers = Get-HttpBasicHeader "user" "password"
#https://jira.<Organization>.mhc/projects/DEV/summary/rest/api/2/issue

$body = ('
{
"fields":
{
"project":
{
"id": "18400"
},

"summary": "Test",

"description": "Test",

"duedate": "2019-05-11",

"issuetype":
{
"id": "10002"
}


}
}')

Invoke-RestMethod -uri $restapiuri -Headers $headers -Method POST -ContentType "application/json" -Body $body

 

I want to create a new issue in JIRA server not in cloud and I used this above script .

But it showing error like...."Invoke-RestMethod : The remote server returned an error: (401) Unauthorized".

It will be helpful ,if someone can help on this.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you