How to change username in jira version 8.2.5 and 8.4.1

Fernando André February 7, 2020

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 7, 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

Fernando André February 11, 2020

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.

Fernando André February 11, 2020

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 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