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.")
Dear @Fernando André ,
as far as I can see, the code seems to be fine. Eventually this function does not work because:
So long
Thomas
So, I tested it and:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
So long
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.