Jira REST API basic auth using API Token returns code 401 (Unauthorized)

Yusuke Nakayama November 19, 2018

Hello Jira expert,

 

I need a help for solving the 401 errors with REST API.

I read several articles on Jira community but still I can't figure out its cause.

 

I follow the steps in

https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/

and then run curl command below.

 

curl -D- \

  -u my_username@my-domain.atlassian.net:MY_JIRA_API_TOKEN \

  -X GET \

  -H "Content-Type: application/json" \

  https://my-domain.atlassian.net/rest/api/latest/issue/PROJECT-131

 

 

and it returns response including  Unauthorized (401) .

I confirmed that my_username can see issue in the PROJECT on the browser.

 

I would appreciate any helps or advice.

 

Thank you

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 3, 2018

Hello Yusuke,

Using the Jira REST API can be excellent for automation and time saving tasks. There is one change I would make to your API call to test. It would be following:

curl -D- \
 -u my_username@my-domain.atlassian.net:MY_JIRA_API_TOKEN \
 -X GET \
 -H "Content-Type: application/json" \
 -H "X-Atlassian-Token: nocheck" \
 https://my-domain.atlassian.net/rest/api/3/issue/PROJECT-131

Along with this, I would also ensure CAPTCHA was not been triggered on the account you are attempting to use. CAPTCHA will also results in all calls failing with a 401. Here is how to reset CAPTCHA for the user:

  1. Click on the Gear icon in the upper right of JIRA

  2. Select User Management

  3. Find the right user

  4. Click on the Reset Failed Login Countlink in the Login Details column.

Source Document: How to reset failed login count from within JIRA

Please let us know if the above assisted with resolving the issue.

Regards,
Stephen Sifers

shawn_rummel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 30, 2020

Stephen, 

 Do you need the "x-atlassian-token: no-check" when you are using an API token? I am working with an integrator to consume there requests. I don't have a way to update their header, but I can create an API token. What can be done when setting no-check isn't possible?

Suggest an answer

Log in or Sign up to answer