The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events