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.")