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.

 

 

3 answers

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

I tried it and it still does not work:

 

PS C:\WINDOWS\system32> # For credentials use email address and API Token
$cred = Get-Credential -Message 'Atlassian Credentials' -UserName 'myemail@mycompany.com' #For password use the API Token

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
New-JiraSession -Credential $cred
DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters:
Key Value
--- -----
ErrorAction Stop

 

DEBUG: [New-JiraSession] ParameterSetName: __AllParameterSets
DEBUG: [New-JiraSession] PSBoundParameters:
Key Value
--- -----
Credential System.Management.Automation.PSCredential

 

DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters:
Key Value
--- -----
Credential System.Management.Automation.PSCredential
Method Get
Headers {}
URI https://mycompany.atlassian.net/rest/api/2/mypermissions
StoreSession True

 

Resolve-DefaultParameterValue : Cannot bind argument to parameter 'Reference' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3215 char:78
+ ... ultParameterValue -Reference $global:PSDefaultParameterValues -Comman ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Resolve-DefaultParameterValue], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Resolve-DefaultParameterValue

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3222 char:9
+ $_headers = Join-Hashtable -Hashtable $script:DefaultHeaders, ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3266 char:13
+ if ($_headers.ContainsKey("Content-Type")) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

DEBUG: [Test-ServerResponse] Investigating $InputObject.Headers['X-Seraph-LoginReason']
DEBUG: [New-JiraSession] Adding session result to existing module PrivateData

PS C:\WINDOWS\system32>

The upgrade to the latest version fixed it.  Thank you.

This is now doing the same thing.  It seems I can log in once with JiraPS and not again for several hours.  I cannot find a way to disconnect whatever is locking me up with Jira.  I have tried it on two computers with the same results.

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