When using the Jira Align Rest API, an http 401 error is reported

Still need help?

The Atlassian Community is here for you.

Ask the community

Summary

This article was explains the possible causes for receiving a 401 error when ujsing the Rest API with Jira Align.

Environment

Jira Align

Diagnosis

The typical error message is shown in the examples below:

Error 401 from Swagger

Error 401 from Postman


Cause

The 401 error is a common error in HTTP requests, this error indicates that the server received an unverified request.

In other words, it is as if the server, which the user is trying to access, does not authorize the access of the user's request. This "no authorization" can occur due to some factors, such as an incorrect URL, an invalid credential (API token typed in the wrong format, for example), DNS errors, firewall problems...

The 401 Unauthorized Error and the 403 Forbidden error are at the same time similar and different. While the 401 Error indicates that the server received an unverified request, a 403 error indicates that although the client provided the needed authentication, they are still not allowed access to the requested resource.


Varying with the browser, the 401 error message may vary, like:

  • HTTP 401 Error – Unauthorized

  • 401 Unauthorized

  • Access Denied

  • Error 401 Unauthorized 


In Jira Align it is very common to face this error when users are making calls to Jira Align Rest APIs.

Solution

The 401 error can be resolved with steps that depend on what is causing the "unverified" request. Therefore, when faced with an error like this you will need to check a few things, described below:


Credentials

(warning) Note: Any examples of bearer tokens shown in this article came from a lab environment and  have been reset so are no longer valid


In Swagger, ( https:// your JA server  /rest/align/api/docs/index.html ) you must enter the correct credentials to authorize calls in the API, as we see in the image below:

  • Enter your credentials following the pattern bearer <API TOKEN>
  • To retrieve your API Token, go to Jira Align > User Menu > Edit My Profile
  • Click on API Token, and if you need it, click on Generate New API Token

  • Copy the string value contained in API 2.0 Token and precede it with the word “bearer ” in the Authorization Value, before clicking Authorize in the Swagger settings.
       Example Value: bearer user:661800|LZy#Yfgmor[JS&okB7HTw~1oOHRc(5t!8hXXXxxx
  • Once you log in using credentials in the provided format, you will be able to use the API, as per  the example below

(info) Note that the server response was 200, which means that the request was valid and, because of that, the server has processed and responded to the user’s request.


Firewall / Cloudflare


When an HTTP 403 error is received, this is likely to be caused by some firewall blocking as the IP that the user is using is not allowed in the API's firewall rules.


However, sometimes a 401 Unauthorized error can be related to your firewall cache.

For example, the firewall may not be communicating correctly with the server, resulting in authentication errors. Assuming the credentials have been validfated (as discussed above and the issue remains) then the fix for this firewall issues, may need customers to contact our support teams as it could be because: 

  1. There is some firewall API rule applied to the Jira Align Instance

  2. There is some cache problem with the firewall of the Jira Align instance instance

  3. There is a region block to the user’s IP Address


Local Issues


It can also occur that only one computer/device in the is suffering from error 401, where users on ojter comopuetrs arfe abnle to iuse the API. The issue may then be related to some problem with the computer being used Let's call this a "Local Issue”. Local issues only happen in one computer is affected among many others in a given environment.

Cache

The browsers store data, so they don't have to load websites from scratch every time you access them. This is known as caching.

There can be invalid log-in information stored locally in your browser that can be disrupting the log-in process and, as a result, throw in a 401 Unauthorized Error.

Fixing this issue is relatively simple. The majority of modern browsers let you clear your cache in a matter of a few minutes.


DNS

Another problem that can give us a 401 error is DNS errors. Although are very rare, they can sometimes cause a 401 Error on your API call. To fix this, all you have to do is flush your DNS records.

Flushing your DNS records means deleting temporary data from a computer. By doing so, the next time we try to access that problematic URL, it'll make a completely new request and re-authenticate.

The process of flushing your DNS varies from one system to another:

If you're a Windows user, you need to open the command prompt and type in the CMD ipconfig/flushdns.

If you're a Mac user, you need to flush your DNS by typing in the command terminal sudo killall -HUP mDNSResponder

For DNS issues, affected end users should get in touch with their company's IT team, in order to analyze and and fix any probable DNS issues.

Related Content:

External References:

401 Unauthorized - HTTP | MDN

How to Fix a 401 Unauthorized Error? - GeeksforGeeks

Postman Support Center | Postman Support Center


Last modified on Jan 26, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.