Getting a 401-Unauthorized Error on REST APi

Chris Voisey November 20, 2017

This one seems to come up from time to time.  It looks like it is back today ... anyone else getting:

Error retrieving data for urlhttps://<domain>.atlassian.net/rest/api/2/field: <html> <head> <title>Unauthorized (401)

 

I tried a direct request through cURL and it responds the same way today.

4 answers

1 accepted

4 votes
Answer accepted
miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 29, 2017

Hi Chris,

REST API needs authentication and that can be achived by various ways, easiest and most common one being Basic Auth (using an HTTP Header encoded in Base64). When you're consulting the API through your browser, if you currently are logged in the application, a cookie is automatically retrieved but if the consumer of the API is a distant resource, it needs to be authenticated.

Did you send authentication credentials along with your request?

Thanks!

Chris Voisey November 29, 2017

Thanks!  Ya, it just started working again later that day.  There was speculation that it was related to the CAPTCHA needing to be refreshed, but that wasn't it.  It just started working with no intervention.  Seems like there are changes being made on the REST system these days.  This also launched the beginning of another issue I am tracking separately now.  

Like Daniel Alonso likes this
miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 29, 2017

Great, glad it worked then! I can guess you're using a cloud instance due to the URL and the REST API might be evolving a lot as you mentioned! usually it does not have a huge impact but might trigger some unexpected behaviours from time to time! Hope it won't affect your instance too much.

Neil McMillan September 18, 2018

I'm hitting this problem too, while trying to use the Cloud REST API:

<html>
<head>
<title>Unauthorized (401)</title>
...trimmed...
<div class="aui-message aui-message-warning warning">
<p>Encountered a
<code>&quot;401 - Unauthorized&quot;</code> error while loading this page.
</p>
<p>
<a href="/secure/MyJiraHome.jspa">Go to Jira home</a>
</p>
</div>
</section>
<!-- .aui-page-panel-content -->

</div>
<!-- .aui-page-panel-inner -->
</div>
<!-- .aui-page-panel -->
</body>
</html>

I have created an API token and am using Postman to issue a GET request to https://<subdomain>.atlassian.net/rest/api/2/issue/XYZ-123

I'm using my email address as the username in Basic Auth, and using the API token as the password. Postman is correctly generating a base64 encoded Authorization header with the value 'Basic <base64 encoded string>'.

Furthermore I have looked at the 'Last accessed' time for the API token (https://id.atlassian.com/manage/api-tokens) to verify that it updates to 'a few seconds ago'

Anyone know what's going on? I never seen any response other than the 401.

Like # people like this
Neil McMillan September 19, 2018

Ah, silly me - it looks like I was using my new updated email address. The one that is displayed on my Jira profile and the one that I use for logging in.

Of course, I should have been using the original email that I used to register with Jira, but haven't been using for the last 6 months.

Sorry for the sarcasm, but come on guys! This is messed up logic and poor documentation.

Like # people like this
David Eedle December 25, 2018

Neil

Saved my life thank you. Been battling 401 all morning. Then saw your post. We sign into Jira with Google Apps. A few months ago we changed our primary Google domain. I was trying to authenticate with my current email address domain.

Swapped to the old domain (which doesn't appear ANYWHERE in Jira I can find) and hey presto now authenticating fine.

 

David

Like hitesh pandey likes this
Michael Rice April 3, 2019

Thanks Neil. 

This was the same for me. I have a SSO with company managed account using a new email and always got 401 with my API token.

After reading your message I remembered that I originally signed up using another email address. Only the original email (which is not visible anywhere on the atlassian portal or profile that I can see) works for me. 

Like # people like this
Ajaya Loya June 7, 2019

iam facing 401 unauthorized. tried using my gsuite email and password? my organization does not allow atlassian user and password auth so how do i proceed on this ?

Garima July 7, 2019

Hi,

I have tried with all mailIDs I could try with. But still I am facing the same error continuously.

How to use Token in Java Rest client. I am using it simply passing as username/password for atlassian account. Should I pass it as a request parameter.

Like # people like this
Amol_Gavali July 9, 2019

Even I am getting the same 401 error. I could successfully log-in  from browser though. There was no captcha on screen. It happens intermittently. It won't work for many days but suddenly it starts working without any change in the code or property. I followed every tutorial and they are all same. Are there any changes in REST implementation from atlassian/JIRA?? I am using basic authentication.

Like Reda EL FANOUI likes this
Guilherme Leme July 10, 2019

Same problem here, I realized it from yesterday, I hate companies that changes things without warning the user in advance and give a solution.

Like # people like this
Brent DeMark July 12, 2019

I'm having the same problem.  Noticed it no longer works yesterday.  The same postman script, email, password, everything.  Whatever changed, it's not on my end.

Brent DeMark July 12, 2019

Looks like this may be the solution to the problem.  Unsername/Paswoord authentication has been deprecated.  

https://community.atlassian.com/t5/Jira-questions/ERROR-quot-message-quot-quot-Client-must-be-authenticated-to/qaq-p/1076087

Like # people like this
Anthony Dinh July 18, 2019

@Brent DeMark thanks for leading me in the right direction. I had the same 401 issue since last week due to the deprecated user/pwd and tried various solutions without any luck.

I just generated a Jira token from my profile security settings, then base64 encoded "login@domain.com:my_token", and passed it as Basic authentication which finally worked.

Sandy Garrido July 29, 2019

Thank Brent - This information was my problem also! 

Pravin Abhale August 7, 2019

Hello everyone,

I also faced the same issue, instead of putting your password, please create API token and put into the password. That works for me.

 

You can create your api key using below link.

https://id.atlassian.com/manage/api-tokens

Thanks 

Like # people like this
hpareta October 28, 2019

A big thanks for this @Neil McMillan

0 votes
Anshul Sharma May 14, 2021

thanks neil.my man

0 votes
Safaa OUM January 30, 2020

@Neil McMillan ,

How can we get the original email?

It works just fine with my jira test instant using my email and the generated token from JIRA, with when i'm trying to connect to jira client, with the email (google account ) and a token of a user but it keeps returning 401 status. How can we get the original email?

 

Thank's in advance.

0 votes
hitesh pandey November 5, 2019

Thanks Neil it worked like charm

Suggest an answer

Log in or Sign up to answer