Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Get group members in JIRA using jira-pyhton

Edited

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

Raised an issue on github for this.

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

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
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