401 Unauthorized error message is displayed JIRA rest api while running Curl command

poovaraj June 1, 2019

 

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>&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>

2 answers

2 accepted

1 vote
Answer accepted
poovaraj June 15, 2019

I am unable to click on accept answer button because it is not displayed 

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 18, 2019

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.

poovaraj June 18, 2019

I got it now and I have accepted answer !

Thank you !  

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 3, 2019

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:

  1. Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens.
  2. Build a string of the form useremail:api_token.
  3. BASE64 encode the string.
  4. Supply an Authorization header with content Basic followed by the encoded string. For example, the string fred:fred encodes to ZnJlZDpmcmVk 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

poovaraj June 13, 2019

It is working now !

Thank you !

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 13, 2019

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

Like poovaraj likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events