It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Try to authenticate with JIRAPS or REST API

PS C:\WINDOWS\system32> New-JiraSession -Credential $cred
WARNING: JIRA returned HTTP error 401 - Unauthorized

 

I have tried using username, email account, Atlassian password and API token.  All fail.

I was getting:

ARNING: JIRA returned HTTP error -
You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\PSJira\1.2.5.251\Public\New-JiraSession.ps1:92 char:13
+ $readStream = New-Object -TypeName System.IO.StreamReader ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

 

And then I saw someone got further by using:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 

And now I only get:

WARNING: JIRA returned HTTP error 401 - Unauthorized

 

I see may articles about deprecating basic authentication.  But using the token for the password is not helping.

 

 

2 answers

0 votes

I was able to get a REST call using Invoke-WebRequest with my email and API token to connect with a return code of 200.  But putting the same in with:

 

New-JiraSession -Credential $Global:cred

 

returns:

WARNING: JIRA returned HTTP error 401 - Unauthorized

 

So is the API call under the hood buggy for JIRAPS?

After reading many blogs and pages I end up with this and works.

# Use https
Set-JiraConfigServer 'https://youcompany.atlassian.net/'

# For credentials use email address and API Token
$cred = Get-Credential -Message 'Atlassian Credentials' -UserName 'your.email@yourcompany.com' #For password use the API Token

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
New-JiraSession -Credential $cred

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

838 views 5 22
Read article

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