Tried a lot of my old code and what ChatGTP and Gemini offers.
In general the latter two messes around regarding the API's that seems to have changed quite a lot around "OrganizationsQuery" ...
Does anyone have a working script?
Hi @Normann P_ Nielsen _Netic_
You can use the API endpoint provided for DC, https://developer.atlassian.com/server/jira-servicedesk/rest/v1103/api-group-organization/#api-group-organization
Or a python script, e.g.:
import requests
BASE_URL = "https://your-jira-instance.com"
AUTH = ('username', 'password_or_token')
HEADERS = {"Accept": "application/json"}
# 1. Fetch Organizations
orgs_resp = requests.get(f"{BASE_URL}/rest/servicedeskapi/organization", auth=AUTH, headers=HEADERS)
organizations = orgs_resp.json().get('values', [])
for org in organizations:
print(f"Organization: {org['name']} (ID: {org['id']})")
# 2. Fetch Users for this Org
users_resp = requests.get(f"{BASE_URL}/rest/servicedeskapi/organization/{org['id']}/user", auth=AUTH, headers=HEADERS)
users = users_resp.json().get('values', [])
for user in users:
print(f" - User: {user['displayName']} ({user['emailAddress']})")
Or query the database:
SELECT
org.NAME AS "Organization Name",
u.lower_user_name AS "Username",
u.display_name AS "Display Name"
FROM "AO_54307E_ORGANIZATION" org
JOIN "AO_54307E_ORGANIZATION_MEMBER" mem ON org.ID = mem.ORGANIZATION_ID
JOIN "app_user" au ON mem.USER_KEY = au.user_key
JOIN "cwd_user" u ON au.lower_user_name = u.lower_user_name
ORDER BY org.NAME;
Or Groovy, but can't test this:
import com.atlassian.servicedesk.api.organization.OrganizationService
import com.atlassian.servicedesk.api.organization.UsersInOrganizationQuery
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
@WithPlugin("com.atlassian.servicedesk")
def orgService = com.atlassian.sal.api.component.ComponentLocator.getComponent(OrganizationService)
def currentUser = com.atlassian.jira.component.ComponentAccessor.jiraAuthenticationContext.loggedInUser
// Define query for all organizations
def orgQuery = orgService.newOrganizationsQueryBuilder().build()
def orgs = orgService.getOrganizations(currentUser, orgQuery).getResults()
orgs.each { org ->
log.info "Organization: ${org.name}"
def userQuery = orgService.newUsersInOrganizationQueryBuilder()
.organization(org)
.build()
def users = orgService.getUsersInOrganization(currentUser, userQuery).getResults()
users.each { user ->
log.info " --> ${user.displayName}"
}
}
That was awesome @Marc -Devoteam- but actually left with a derived issue:
A Service Desk customer placed with no Org and no role - is still a Service Desk Customer:
So I have Project Id and Service Desk Id - but no Org Id ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Normann P_ Nielsen _Netic_
SD customers, not linked to an Org don't has and Org ID set.
So this why you will not see na ORG ID at customers not linked to an Org.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah - but that kind of leaves my "Access Management" reporting going only half way...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I seem to be able to get them at:
https://jira.server.dk/rest/servicedesk/1/pages/people/customers/pagination/XXX/search?query=&page=1
Where XXX is project Key...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use this api to get all users in a JSM organization:
The Jira Service Management Cloud REST API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The tags on the question indicate @Normann P_ Nielsen _Netic_ is running Jira on DC, so the provided cloud api option will not fulfil his need.
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.