HI,
please, can someone help me with Python 3 code to extract from Jira the list of all users and their email addresses?
Code used:
import jira.client
from jira.client import JIRA
import urllib3
urllib3.disable_warnings()
jira = JIRA(options={'server':'https://jiraDOMAIN.com', 'verify':False}, basic_auth= ('name','password#'))
import requests
import json
url = "https://<jiraDomain<.com/rest/api/2/user/search?startAt=0&maxResults=1000"
headers = {
"Accept": "application/json",
"Bearer": "access token"
}
response = requests.request(
"GET",
url,
headers=headers,
verify=False
)
print(....)
The result that's needed:
User Email
name1 name1@email.com
name2 name2@email.com
etc
Thanks for any help!
Hi @Lucie Krennwallner ,
I would recommend using this jira library.
Then you can loop through users in a certain group and print what you're looking for.
For example:
for user in jira.group_members("jira-administrators"):
info = jira.user(user)
print(info.name, info.emailAddress)
or you can also loop through all groups
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for user in jira.group_members("jira-administrators"):
the above will pull the user key
info = jira.user(user)
the second will search for username,
and throiwng error if key and username is different
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.