Hello,
I recently lost the ability to login to the Jira REST API using powershell, constantly getting 401 unauthorized errors. My account has admin privileges and I know I'm using the correct password. Anyone might know what I'm doing wrong?
Invoke-RestMethod -UseBasicParsing -Method Post -Uri "https://15sof1.atlassian.net/rest/auth/1/session" -SessionVariable session -Body (@{username = $username; password = $password} | convertTo-Json -Compress) -ContentType 'application/json'
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-RestMethod -UseBasicParsing -Method Post -Uri "https://15sof1. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Thanks!
Hi all,
I was working with Austin on a related post and I think we found the solution.
Atlassian Cloud recently deprecated support for TLS 1.0 and 1.1 protocols. This will force all clients to support TLS 1.2 in order to connect. Deprecating TLSv1 and TLSv1.1 for Atlassian Cloud Products has more details.
While the planned effective date in that page was December 1, 2018, you can see in the recent Jira Cloud blog updates in https://confluence.atlassian.com/cloud/blog/2019/07/atlassian-cloud-changes-jul-1-to-jul-8-2019
... after consultation internally and with customers, we have allowed a silent/soft grace period of 6 months to allow customers additional time to update the necessary tools and systems. This grace period has now expired.
In my search I came across this post:
https://www.codyhosterman.com/2016/06/force-the-invoke-restmethod-powershell-cmdlet-to-use-tls-1-2/
The issue, as I understand it, is that PowerShell by default uses TLS 1.0 for web requests, which will not work in our case. So this needs to be changed. Thankfully, this is an easy change. Just add the following line to your scripts:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Which means that we would need to make sure powershell is using the TLS v1.2 protocol when trying to connect to an Atlassian Cloud address, or else it won't be able to connect.
Cheers,
Andy
Still facing the same problem with API token, any other suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Create an API token and replace your password with it:
https://confluence.atlassian.com/cloud/api-tokens-938839638.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm still getting the same error with the API token:
Invoke-RestMethod -UseBasicParsing -Method Post -Uri "https://15sof1.atlassian.net/rest/auth/1/session" -SessionVariable session -Body (@{username = $username; password = $apitoken} | convertTo-Json -Compress) -ContentType 'application/json'
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-RestMethod -UseBasicParsing -Method Post -Uri "https://15sof1. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried that approach with Postman only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.
Learn moreOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.