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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get issue history with JIRA API?

Hi,

I am a very new user to Jira and Jira API. I am required to export from JIRA website a bunch of issues history in an excel file. 

I have read in many forums that you need whether an extension or that I could write a request in Jira Api. As i am very new to Python and programming, i don't know how to write such a program using the url to extract all the issue history, I have tried but it is not working.

Could you please help me with the issue? 

PS: I want the issue history in order to figure the number of ticket reopening and there status (closed, resolved and closed)

1 answer

0 votes

Hello @Elshy 

Welcome to the community

Are you sur that you need to use API for this. It seems that you just need to write a JQL to be able to find the number of ticket.

Closed ticket :

project = "ABC" ans status in ("Closed")

 Resolved ticket :

project = "ABC" and resolution in ("Resolved")

 reopened ticket :

project = "ABC" and status changed from "Closed" to "Reopen"

 You can add date to narrow your search :

project = "ABC" ans status in ("Closed") and createddate >=StartofMonth(-1) and createddate <= EndofMonth(-1)

This query will find all issue closed in the project ABC that where created the previous month.

With JQL you will be able to export your result in CSV.

 

https://confluence.atlassian.com/jirasoftwareserver086/saving-your-search-as-a-filter-990555095.html

https://confluence.atlassian.com/jirasoftwareserver086/working-with-search-results-990555156.html

 

Hope this helps

Hi,

 

Thanks for your kind help and sorry for my late answer.

Unfortunately i already tried this, it worked but it does not give me what i want. What i am looking for is how much items have been reopened (what the Jira query gives) but also HOW MANY times an item as been reopened (most of my items have been reopened twice), as i have almost 500 items i would like to avoid doing it manually... My final aim is to calculate a reopen rate....

 

If you have any idea on how to help with these precision i would be really happy :)

Here is the python i tried to write but as i am very new to python and programming it kept failing hahaha...

 

 

import requests
import json
from openpyxl import load_workbook
import html
from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font, NamedStyle
import datetime
from openpyxl.styles.colors import ColorDescriptor, Color
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile


headers = {
'proxy-authorization': 'Basic UElENjNEQjpQYXNzd29yZDEyMzQ=',
'authorization': 'Basic UElENjNEQjpQYXNzd29yZDEyMzQ='
}

#EXCEL CREATION
Today = str(datetime.datetime.now()).split(".")[0].replace(':', '_')
wb = load_workbook(filename='C:/Users/ESABIRB/Desktop/Issuehistory.xlsx')
wb.save(Excel)

wb = load_workbook(Excel)
EX = wb['JiraData']

#JIRA API REQUEST
r = requests.get('https://jira-dsc.apac.bg.corpintra.net/rest/api/2/search?XXXXXXXXXlink', headers=headers, verify=False)
issue = requests.get('https://jira-dsc.apac.bg.corpintra.net/browse/issue', headers=headers, verify=False, expand='changelog')
#issue = r.issue('NGT-25021', expand='changelog')
changelog = issue.changelog

for history in changelog.histories:
for item in history.items:
if item.field == 'status':
print ('Date:' + history.created + ' From:' + item.fromString + ' To:' + item.toString)

Hello @Elshy 

Here a code, i used the jira modul for python :

from jira import JIRA
jira_server = JIRA(basic_auth=("username","password"), options={'server''https://URL'})
issues_Jql = jira_server.issue('your issue',expand='changelog')#pass one issue at the time  
#print(issues_Jql)
changelog = issues_Jql.changelog
count = 0
for history in changelog.histories:   
for item in history.items:        
if item.field == 'status':            
if item.toString == "Reopened":                
count = count + 
1            
print(count)   

Hi, 

thanks again for this very useful help. One last question do you know what i should put instead your issue to have the number for all issues?

 

Thanks a lot :)

Hi, you need something like that:

dictionnary = {}
for
 i in jql_search:    
count = 
0    
for history in jira_server.issue(i.key, expand = 'changelog').changelog.histories:              
for item in history.items:                   
if item.field == 'status'                       
if item.toString == "Done":
  
                            
count += 
1                            
dictionnary[i.key] = count      

Hope this helps

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you