401 Unauthorized error message is displayed JIRA rest api while running Curl command. Company is enabled SSO login. Can you please let me know how to fix this issue ?
curl -H "Authorization: Basic fZPwga3cWDBWSAb135VherrrrD16B" -X GET -H "Content-Type: application/json" https://company.atlassian.net/rest/api/2/issue/
<meta name="application-name" content="JIRA" data-name="jira" data-version="1001.0.0-SNAPSHOT">
</head>
<body id="jira" class="aui-layout aui-style-default page-type-message" data-version="1001.0.0-SNAPSHOT" >
<div class="aui-page-panel"><div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<header class="aui-page-header"><div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h1>Unauthorized (401)</h1>
</div><!-- .aui-page-header-main -->
</div><!-- .aui-page-header-inner --></header><!-- .aui-page-header -->
<div class="aui-message aui-message-warning warning">
<p>Encountered a <code>"401 - Unauthorized"</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 am unable to click on accept answer button because it is not displayed
Ah, from looking at the account you used to create the original question, it appears you have two different accounts with our Community site, (profile link #1 and profile link #2) and you're currently signed in with the other account. As such, you can only accept answers from the account that created the question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I understand you are seeing this 401 error in curl when trying to make requests to your Jira Cloud site that appears to have SSO enabled.
You should still be able to utilizing basic auth for Jira Cloud REST API requests, but in order to do so, there are a few things you will need to make sure you have correct. Please see the details in Basic auth for REST APIs. Specifically the example in
Supplying basic auth headers
If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:
- Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens.
- Build a string of the form
useremail:api_token
.- BASE64 encode the string.
- Supply an
Authorization
header with contentBasic
followed by the encoded string. For example, the stringfred:fred
encodes toZnJlZDpmcmVk
in base64, so you would make the request as follows:curl -D- \
-X GET \
-H "Authorization: Basic ZnJlZDpmcmVk" \
-H "Content-Type: application/json" \
"https://your-domain.atlassian.net/rest/api/2/issue/QA-31"
It is possible in older versions of Jira Cloud that you might have just used a username and password, but in the current state, you are expected to use the useremail address in conjunction with the api_token created for your account and then base64 encode that string.
I would want to confirm that you are using these settings first to make sure your authorization header is correct here.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great, glad to hear it. If you don't mind, please click the 'accept answer' button next to my answer if this helped to resolve the problem.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.