change domain mail in jira cloud

Kader Price August 25, 2024

 

 

Hello 

i have multiple users in "user management" and i need to change the domain @TEST.com to testy.com for +1000 users and i found a script python but don't worked 

this is script pyhton

---------------------START SCRIPT-----------------------------------------

 

import requests
import csv
JIRA_EMAIL = 'xxxxxxx@xxxxxx.com'
JIRA_API_TOKEN = 'xxxxx-TOKEN-XXXXX'
CSV_FILE = r'C:\Users\XXXXX\Documents\import-users.csv'

print("JE LIS LE FICHIER")
OLD_DOMAIN = '@test.com'
NEW_DOMAIN = '@testy.com'
with open(CSV_FILE, newline='') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        old_email = row['email']  # Colonne de l'email existant dans le CSV
       
        if OLD_DOMAIN in old_email:
            new_email = old_email.replace(OLD_DOMAIN, NEW_DOMAIN)
           
            url = f"https://xxxxxxx.net/rest/api/3/user?accountId={row['account_id']}"
           
            payload = {
                "emailAddress": new_email
            }
           
            response = requests.put(url, json=payload, auth=(JIRA_EMAIL, JIRA_API_TOKEN))
           
            if response.status_code == 204:
                print(f"L'email de {old_email} a été mis à jour avec succès en {new_email}.")
            else:
                print(f"Erreur pour {old_email}: {response.status_code} - {response.text}")
        else:
            print(f"Aucune modification nécessaire pour {old_email}.")
------------------ END SCRIPT---------------------

 

have you another idea for i can do this ?

Thanks in advance

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2024

Hi,

do you have an error or the mail is not updated ?

Suggest an answer

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

Atlassian Community Events