Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to change username in jira version 8.2.5 and 8.4.1

I'm trying to change the name of the username and email with the below python code this by using the restapi , but the restapi returns the user information but does not change anything.

 

Any ideas?

 

from pprint import pprint
import json
import requests
from requests.auth import HTTPBasicAuth

HTTP_URL = "http://jira/rest/api/2"

def putApi(url, info):
try:
print("User: " + USER + " Pass: " + PASS )
response = requests.put(url,data=json.dumps(info), auth=(USER, PASS),verify=False)
except requests.exceptions.HTTPError as err:
print("Error HTTP happened: result:"+ str(err) )
return False, err
except requests.exceptions.RequestException as err:
print("Error HTTP happened: result:"+ str(err) )
return False, err
# responsedata = response.json()
if response.status_code != 200:
print("Issue with status code..." + str(response.status_code) )
return False, str(response.status_code)
# print(response)
responsedata = response
return True, responsedata

 

def updateUsernameEmailByUsername(username, new_username, email):
data = { 'username': new_username, 'emailAddress': email , "displayName": "Fabio"}
http_url = HTTP_URL + "/user/?username=" + username
res, response = putApi(http_url, data)
pprint(response.text)
if res == True:
print("username: " + username + " : updated.")
else:
print("username: " + username + " : failed.")

 

1 answer

0 votes
Thomas Deiler Community Leader Feb 07, 2020

Dear @Fernando André ,

as far as I can see, the code seems to be fine. Eventually this function does not work because:

  • the api call is marked as experimental.
  • the user to modify is member of a Read-Only directory server (LDAP, ...)
  • the query parameter "key" is missing

So long

Thomas

So, I tested it and:

  • the api call is marked as experimental.
    Yes!

    How can I change the username and e-mail of several users by the database or other method?

  • the user to modify is member of a Read-Only directory server (LDAP, ...)

    He is a member of Jira System.

  • the query parameter "key" is missing

    Added the key parameter and the same problem happened.

Found the table and the field:

select * from cwd_user where email_address like 'email@domain.com';

 

Is it safe to change the username here?

Can it impact other things?

Thomas Deiler Community Leader Feb 12, 2020

Dear @Fernando André ,

Atlassian does not recommend to do direct changes in DB unless you really know what you are doing. Nevertheless if you plan to proceed:

  • stop Jira before
  • make a backup
  • try first on  test environment

So long

Thomas

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you