Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I check if everyone in my Team have phone numbers assigned to their Jira Profile

Tamiko
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 19, 2024

Since the migration of Opsgenie to Jira we have trouble with functionality, mainly the unavailability to see/check from UI if the user have their phone number added to profile. It's crucial for the Alerting/Paging functionality.
Anyone have idea on how to solve this mistery?

1 answer

1 vote
Mikel Garcia Bartolome
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2024

To address the issue of checking if users have their phone numbers added to their profiles in Jira Cloud (post-migration from Opsgenie), we can leverage the Jira Cloud REST API. Unfortunately, Jira's UI might not provide a direct way to view user profile details such as phone numbers, but the API can be a powerful tool for retrieving this information.

Here’s a detailed guide on how to check users’ phone numbers using the Jira Cloud REST API:

Step 1: Obtain API Access

Ensure you have the necessary permissions to access the Jira Cloud REST API. You will need an API token for authentication. You can generate an API token from your Atlassian account:

  1. Go to [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens).
  2. Click on "Create API token".
  3. Name your token and click "Create".
  4. Copy the token and store it securely.

Step 2: Write a Script to Fetch User Details

You can use Python to write a script that fetches user details, including their phone numbers. Here is an example script:

import requests
from requests.auth import HTTPBasicAuth
import json

# Your Jira Cloud instance details
JIRA_URL = "https://your-domain.atlassian.net"
API_TOKEN = "your_api_token"
EMAIL = "your_email@example.com"

# Function to fetch user details
def get_user_details(username):
url = f"{JIRA_URL}/rest/api/3/user?username={username}"
auth = HTTPBasicAuth(EMAIL, API_TOKEN)
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
return json.loads(response.text)

# Function to check if a user has a phone number
def check_phone_number(username):
user_details = get_user_details(username)
if 'phone' in user_details:
return user_details['phone']
else:
return "No phone number added"

# List of usernames to check
usernames = ["user1", "user2", "user3"]

# Check phone numbers for each user
for username in usernames:
phone_number = check_phone_number(username)
print(f"Username: {username}, Phone Number: {phone_number}")

Step 3: Run the Script

Save the script and run it in your Python environment. The script will output the phone number for each user if available, or indicate that no phone number is added.

Automating the Process
To automate this process, you can set up a cron job (on Unix-based systems) or a Task Scheduler (on Windows) to run the script at regular intervals.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events