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

Getting a 401-Unauthorized Error on REST APi

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.

1 answer

1 accepted

0 votes
Answer accepted
Micky CARITTE Community Leader Nov 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!

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.  

Micky CARITTE Community Leader Nov 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.

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 1 person likes this

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 1 person likes this

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

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. 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 09, 2019 in Portfolio for Jira

Portfolio for Jira 3.0 is here!

The wait is over... Portfolio for Jira Server and Data Center 3.0 is now officially here! Platform releases offer Atlassian an opportunity to shift our strategy, make bold predictions about t...

1,595 views 14 26
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you