Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Jira API + Python

Thiago Portocarrero de Lima
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!
Oct 06, 2023

Hello!

By reading some other discussions here on the community, and in other sites, I've wrote a few python codes trying to get my Jira information into a dataframe and use it. Let me show some attempts:

#1

import requests
import json

url = 'https://URL.atlassian.net/rest/api/3/search?jql=project%20%3D%20PROJECTNAME%20ORDER%20BY%20updated%20DESC&maxResults=100&startAt=0&fields=*all,-comment'

header = {
"Autenticate": "TOKEN"
}

request = requests.get(url, headers=header)
resp = json.loads(request.content)
print(resp)

 

#2

from jira import JIRA

jira = JIRA(basic_auth=('USER', 'PASS'), options={'server':'https://URL.atlassian.net'})

def get_all_issues(jira_client, project_name, fields):
    issues = []
    i = 0
    chunk_size = 100
    while True:
        chunk = jira_client.search_issues(f'project = {project_name}', startAt=i, maxResults=chunk_size, fields=fields)
        i += chunk_size
        issues += chunk.iterable
        if i >= chunk.total:
            break
    return issues
issues = get_all_issues(jira, 'PROJECTNAME', ["id", "fixVersion"])

 

#3

from jira import JIRA

jira = JIRA(server='https://URL.atlassian.net', basic_auth=('USER', 'PASS))

issue = jira.issue('PROJECTNAME-xxx')
print(issue.fields.summary)

 

#4

from atlassian import Jira

jira = Jira(

    url='https://URL.atlassian.net',

    username='USER',

    password='PASS',

    cloud=True)

JQL = 'project = PROJECTNAME ORDER BY updated DESC'

data = jira.jql(JQL)
print(data)

 

In all of these i got the error (or similar):

{"errorMessages":["The value 'PROJECTNAME' does not exist for the field 'project'."],"warningMessages":[]}

 

What is missing from my code to connect to the API and get all issues on my project? (about 4k issues there that i'm trying to analyse)

 

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 08, 2023

Make sure that you're using basic auth in your first script. Then make sur that you have the correct permission in the project.

Thiago Portocarrero de Lima
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!
Oct 09, 2023

By basic auth you mean use 
header = {username='USER', password='PASS'}??

 

And by correct permission you mean admin? I am

Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 09, 2023

https://requests.readthedocs.io/en/latest/user/authentication/

with requests you can use this

requests.get('https://httpbin.org/basic-auth/user/pass', auth=('yourMailAddress', 'Token'))

You need to have access to the project to be able to get the data by API. Do you have access to the issue in the UI ?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events