Get group members in JIRA using jira-pyhton

Ulrich EKEU MONKAM March 4, 2020

Hello,

I am trying to get all users from the group jira-users from a hosted jira account. 

 

This is a solution that i tried figuring ou t and which i also found within the community and on the when i googled my problem.

 

from jira import JIRA
from jira.exceptions import JIRAError
import datetime
import requests
from requests.auth import HTTPBasicAuth
import json

def All_Jira_Users():    
users = jira.group_members("jira-users")
print(users)

 

When executing this, here is what i'm getting

Traceback (most recent call last):
File "d:/JIRA_KPI/venv/jiraKpi.py", line 178, in <module>
All_Jira_Users()
File "d:/JIRA_KPI/venv/jiraKpi.py", line 168, in All_Jira_Users
users = jira.group_members("jira-users").items
File "D:\JIRA_KPI\venv\lib\site-packages\jira\client.py", line 1011, in group_members
result[user['key']] = {'name': user['name'],
KeyError: 'name'

 

Thanks for your help 

2 answers

0 votes
Ilgiz Nurgaliev October 19, 2020

Raised an issue on github for this.

0 votes
Laimonas Sutkus September 24, 2020

Does anyone know the answer? I am getting exactly the same problem.

Jarlen Caden November 29, 2021

Yes, you need to update the client.py file.

 

For Anaconda, this is located here:

C:\ProgramData\Anaconda3\Lib\site-packages\jira\client.py

 

The latest version of Jira does not support the key "name" or "key", so change the code lines that start at line 1205 to:

for user in r["users"]["items"]:
result[user["accountId"]] = {
"fullname": user["displayName"], 
"email": user.get("emailAddress", "hidden"),
"active": user["active"]
}

 

NOTE three changes: 

1. Remove the line that says "name", since that is no longer available in the JSON feed from Atlassian. You can use "fullname" to reference a person's name.

2. Change "key" to "accountId" since "key" is also no longer available.

3. Remove the last comma at the end of the line "active": user["active"]

 

Save the changes back to the same folder and restart your python (or Jupyter if you use that) kernel before re-running your code. 

Suggest an answer

Log in or Sign up to answer