How do I display all issue fields in the Python Jira API?

Sergio Rodriguez June 22, 2020

For anyone here who has used Jira-Python, if I'm using vim to edit my code, how do I display all issue fields for my project? 

 

Here is the link of the doc 

https://jira.readthedocs.io/en/master/

 

and attached picture showsissue fields.png all the common fields of an issue but my companies fields might be different. 

5 answers

1 vote
Bilal Khan June 23, 2021

You can use 

issue.raw['fields']

to get all the results obtained in the JSON object as raw string. Its not as pleasant to view, but will provide you with what you're looking for.  Take a look at this stackoverflow solution  and see if you find your answer, cheers.

Bilal Khan September 17, 2021

I made a web application using plotly/dash on Python to make an interactive Jira work log dashboard. Users who are viewing the answer to this question might find something valuable there.  You can visit this GitHub repository.

Like Moutaz Gendia likes this
Steve Suranie December 7, 2022

I know this is old but this might help someone else down the road. You can do this to just get the field names: 

print(sorted(thisIssue.raw['fields'])

if you even better clarity (but more scrolling), you can put them each on a newline: 

print("\n".join(sorted(thisIssue.raw['fields'])))

Like Dad likes this
0 votes
Steve Suranie December 7, 2022

I added this to an answer above but thought I would expand it here: 

I'm using this JQL to get issues that fall within a date range for a project: 


from jira import JIRA
from jira.client import ResultList
from jira.resources import Issue
import os
import datetime
import json

#set date ranges
dtOneYearPast = datetime.datetime.now() - datetime.timedelta(days=3*365)
dtThreeWeeksPast = datetime.datetime.now() - datetime.timedelta(days=21)

#convert to strings
strOneYearPast = formatDateString(dtOneYearPast)
strThreeWeeksPast = formatDateString(dtThreeWeeksPast)

strJQL = "project=KME AND status = 'Code Review' OR status = 'IN QA - DEV' OR status = 'IN QA - STG' AND createdDate > " + strOneYearPast + " AND createdDate < " + strThreeWeeksPast

and grabbing the first response and outputting the fields, sorted ascending, each field on its own line here: 



for thisIssue in jira.search_issues(strJQL, maxResults=250, expand='changelog'):
print("\n".join(sorted(thisIssue.raw['fields'])))
break


0 votes
A low hanging fruit June 30, 2021

I would go this way:

project_keys = ['Zen']
issuetype_names = ['Task']
meta = jira_instance.createmeta(projectKeys=project_keys,
issuetypeNames=issuetype_names,
expand='projects.issuetypes.fields')

for x in meta:
...

Basically gives you all info, datatypes, options etc. attached to the individual fields in the corresponding project/issuetype. This also gives you the field name to the customfield_123456 fields, translations etc.

0 votes
Fabio Araujo Jardim April 20, 2021

Were you able to do this? Trying the same thing and having a fairly hard time.

0 votes
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 28, 2021

Hi! 

Please, try to use the Pycharm, or vs code to edit. 

regarding to view in one shot I do recommend a look into postman side

Suggest an answer

Log in or Sign up to answer