How to get the Role Name for Jira Align Users

Still need help?

The Atlassian Community is here for you.

Ask the community

Summary

Sometimes it is necessary to generate a report of Jira Align Users containing the Role Name for each user. This article shows how to get/retrieve Role Names of Jira Align Users


Environment

Jira Align


Solution

There are multiple ways to get the Role Name information for Jira Align Users, 3 such methods are discussed in the following sections


Approach 1 - Via Jira Align UI

Pros

Cons

No additional knowledge, on Jira Align side, is required;

Additional actions on Excel are required to filter full data;

By exporting the data once, you will have a list of all users;

There is no way to get a JSON response;

It is possible to filter (by First Name, Last Name, Email address, Region, etc) before export the Full Data


Steps to be followed:

  1. Go to Jira Align > Settings / Administration > ACCESS CONTROLS section > People

  2. Click on the button More Actions > Export

  3. Save the Excel file generated

In the column Role of the Excel file generated, the Role Name for each user is available


Approach 2 - Via API Calls

Pros

Cons

It is possible to filter (by First Name, Last Name, Email address, Region, etc) before run the API Call

Basic API Calls knowledge is required;

The API Call can be used on an own script

Due to the number of records that can be returned in a GET API call, in Jira Align there is a limitation of 100 items to be returned in a single call. If you have 200 items to be returned, two calls are required, if you have 300 records to be returned, three calls are required, and so on. Using Pagination, you must loop through batches of 100 to get all items.


It is required to create/adjust a script to parse Users' elements to get the Role Name

Steps to be followed:

  1. Using Jira Align Swagger and/or an API Client (Postman, Insomnia, etc) make a call on Users endpoint passing id=[UserID] and expand=true parameters. The GET API Call should be something similar to:

    https:// Your-JiraAlign-Server /rest/align/api/2/Users?id=1&expand=true

The Response Body will be similar to the one below:



[
	{
		"id": 1,
		"uid": "1",
		...
		"role": {
			"id": 9,
			"name": "Super Admin",
			"description": null,
			"type": null,
			"createDate": null,
			"updateDate": "2023-06-22T09:51:09Z",
			"isTimeTracking": null,
			"isSystemRole": true,
		},
       ...
]



If familiar with using Python scripting with API calls then more complicated queries are possible - for instance, the following Python Script retrieves a user based on the email address and then parses the User’s elements to get the Role Name:


import requests

base_url = "https://YOUR_COMPANY.jiraalign.com/rest/align/api/2"
bearer_token = "ENTER_YOUR_API_Token"

def get_user_role_and_id(email):
    url = f"{base_url}/Users"
    headers = {
        "Authorization": f"Bearer {bearer_token}"
    }
    params = {
        "email": email,
        "expand": "true"
    }

    response = requests.get(url, headers=headers, params=params)
    response.raise_for_status()
    user_data = response.json()

    if user_data:
        user = user_data[0]
        user_id = user.get("id")
        role = user.get("role")
        if role:
            role_name = role.get("name")
            return user_id, role_name
        else:
            return user_id, None
    else:
        return None, None

# Specify the email of the user to fetch the role and ID
user_email = "PROVIDE_THE_EMAILID_OF_THE_USER"

# Get the role and ID of the user
user_id, role_name = get_user_role_and_id(user_email)

# Print the role, ID, and email
if user_id and role_name:
    print(f"User ID: {user_id}")
    print(f"Role: {role_name}")
    print(f"Email: {user_email}")
else:
    print("User not found.")



Approach 3 - Via Enterprise Insights


Pros

Cons

No additional knowledge, on Jira Align side, is required;

Enterprise Insights instance is required;

By exporting the data once, you will have a list of all users;

There is no way to get a JSON response;

It is possible to filter (by First Name, Last Name, Email address, Region, etc) before export the Full Data

To run the queries you need any tool to access, administer, and manage SQL Server databases. The most commons in use by our customers are:

  • Azure Data Studio

  • SQL Server Management Studio

  • Power BI Desktop


Steps to be followed:


  1. Connect to Enterprise Insights instance using one of the mentioned tools listed o above;

  2. Run a query, accordingly to your requirements, on the [User] table. The following query can be used as a reference:

    SELECT * FROM [current_dw].[User] where [First Name]='John'
  3. Role Name will be available in the [Role Name] column



Related Content:

API 2.0 GET usage and filters

Getting started with the REST API 2.0

Enterprise Insights schema






Last modified on Jan 26, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.