Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a query of my Jira tasks using an API-key

Iddo Weiner
Contributor
July 19, 2020

Hey,

I am trying to query Jira (cloud) using API.

I generated an api-key and ran a quick python script as suggested in several places, such as:

https://stackoverflow.com/questions/12098333/querying-jira-with-python-and-rest

(I also found very similar code snippets here on Atlassian community).

However, I keep getting the same error message:

JIRAError: JiraError HTTP 401 url: https://<myurl>.atlassian.net/rest/api/2/serverInfo
text: Basic authentication with passwords is deprecated. For more information, see: https://confluence.atlassian.com/cloud/deprecation-of-basic-authentication-with-passwords-for-jira-and-confluence-apis-972355348.html

So - the API is failing, and it points me to a deprecation link (though I noticed that it points there even with random erroneous input, so it might not be specific to my bug).  

Any idea what I'm doing wrong? My code is provided as well, however it's basically copy paste from stack overflow:

from jira import JIRA

apikey="mykey"
user = 'me@comp'
server = 'https://<comp>.atlassian.net'
options = {'server': server}

jira = JIRA(options, basic_auth=(user,apikey) )

 

1 answer

0 votes
Italo Qualisoni [e-Core]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2020

Hi @Iddo Weiner ,

I think you are in the right path, I've seen some issues in previous questions that the APIKEY was not copied correctly and generated this error.

Can you generate a new API Key and re-test it ?

https://confluence.atlassian.com/cloud/api-tokens-938839638.html

Iddo Weiner
Contributor
July 20, 2020

Hey @Italo Qualisoni [e-Core] , thanks for answering.

I created a new APIkey, copied it carefully to my code snippet (made sure by eye that it was copied correctly) and ran it again.

I got the same result :/

Maybe I am missing a step? Is there supposed to be an earlier step where I enable API access to the account or something like that?

Italo Qualisoni [e-Core]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 20, 2020

After you create a new API Key you should be good to use the API using it.

You can check if you are using the correct email as your user variable in your script? Your email is the last item in this page:

https://id.atlassian.com/manage-profile/profile-and-visibility

Iddo Weiner
Contributor
July 21, 2020

hmmm I am using the correct email.. :/

Italo Qualisoni [e-Core]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2020

So you are doing it right, maybe it's something related with your python library?

You can try with curl with something like this

curl -v https://mysite.atlassian.net/rest/api/2/serverInfo --user me@example.com:my-api-token
Iddo Weiner
Contributor
July 22, 2020

Get the same error with curl.

Pretty sure there's a permission problem (401), but I can't understand why..?

Claus Toftegaard Matthiesen
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!
September 29, 2021

I am getting the exact same problem: Using correct e-mail and api key. Did you find an answer?

io
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!
November 2, 2021

I have the same problem as well.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events