Why JIRA rest api is returning 401 every time I generate a request from postman?

wasifale
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!
July 3, 2019

Hi,

I'm trying to make a call to JIRA rest api using the API token from Postman,
I have created the API token from API token,
Now when I send a request to,

https://abc.atlassian.net/rest/api/3/issue

with body

{
"auth": {
"bearer": "<my_token>"
}
}

 

it should return all issues, but in real it is returning a 401 unauthorized  error. Any help will be appreciated,
Thanks

Note:
token is generated from the admin account.

3 answers

1 vote
Daniel Crouch July 3, 2019

Not able to answer this for you, but I am also experiencing this problem.

I had a stable integration running that has not changed but suddenly stopped working on Monday

0 votes
Chen Gao
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!
January 30, 2021

I also have the same problem on postman when I am trying to post a request to create a issue.  I am using the jira server version, not cloud. 

Headers: Content-Type applicaiton/Json, Authorization Basic encodeusername:api token. 

URL: http://localhost:8080/rest/api/2/issue

Any idea what is wrong of my request? 

0 votes
Daniel Crouch July 4, 2019

Very oddly, I was previously calling the api with curl like this:

curl -v "https://mysite.atlassian.net/rest/api/2/search?jql=project=ABC+and+issueKey+in+(ABC-123)&fields=summary" -H "Authorization: Basic MY-API-TOKEN"

 

Which was working fine until Monday, since which I have been receiving a 401 response.

 

Reading the official support documentation on the api tokens page (https://confluence.atlassian.com/cloud/api-tokens-938839638.html) they advise to use your username and password colon separated on the user param e.g.:

curl -v https://mysite.atlassian.net --user me@example.com:my-api-token

This did not work for me.

 

Further reading (https://community.atlassian.com/t5/Jira-questions/JIRA-Rest-API-authentication-always-returns-401-unauthorized/qaq-p/187181), advised the approach is to use your username and password colon separated and then base64 encode it e.g.

me@company.com:MY-API-TOKEN

This base64 encode is (using https://www.base64encode.net/):

bWVAY29tcGFueS5jb206TVktQVBJLVRPS0VO

Therefore the curl request would then be:


curl -v "https://mysite.atlassian.net/rest/api/2/search?jql=project=ABC+and+issueKey+in+(ABC-123)&fields=summary" -H "Authorization: Basic bWVAY29tcGFueS5jb206TVktQVBJLVRPS0VO"

 

And this worked for me.

Daniel Crouch July 4, 2019

With using Postman, all you need do is in the Headers tab, create a `Authorization` header with value `Basic encodedusername:apikey` e.g.

 

Screen Shot 2019-07-04 at 09.06.53.png

deepak_kumbhar46
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!
March 28, 2022

Basic has been deprecated. You need to use another authentication mechanism, but the real question was related to the Bearer token, I am facing the same issue. Any luck here?

Suggest an answer

Log in or Sign up to answer