2

I'm writing a python script and trying to get the project category using the jira-python package. If I retrieve the project using the API, there is a category object.

However in the python script, if I try to get the category name element from the project (jiraProject.projectCategory.name), it errors and doesn't seem to be found. Would this be an issue with the jira-python package? Is there any way around this or do I have to execute the REST API myself and not use jira-python?

2 Answers2

3

There should be a projectCategory attribute if the project in question has a category assigned. This attribute won't be present if the category is not assigned. The following example reads and prints the category if one exists using jira-python.

jira = JIRA(...)
for p in jira.projects():
    if hasattr(p, "projectCategory"):
        print(p.projectCategory.name)
ehambright
  • 1,416
  • 19
  • 27
1

It appears that the ProjectCategory resource is not implemented in the current version of jira-python. However, you can still access the information.

j = JIRA(...)
proj = j.project(id)
category = proj.projectCategory
category_name = category._session['name']

The _session attribute is a dictionary that contains 'name','id','description'

ZeddZull
  • 276
  • 1
  • 4