How to disable multiple users in Jira Cloud by script

Manikanta Maram March 17, 2020

How to disable or deactivate multiple users in Jira Cloud by script

1 answer

0 votes
Manikanta Maram March 17, 2020
import csv
import requests

def main():
    # Base url, path and the instance's cloud id get it from admin.atlassian.net
    cloud_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 
    # Open the .CSV file with the users id and email
    with open('Jira_Users.csv', mode='r') as infile:
        reader = csv.reader(infile)
        for row in reader:
           full_url = "https://admin.atlassian.com/gateway/api/adminhub/um/site/<cloud_id>/users/<user_id>/deactivate"           # Print a confirmation of which user it is trying to remove
           print("Processing removal of id: " + row[0] + " with email: " + row[2])
           # Creates a varible with the complete url
           # Print the full URL just to ensure that we are using the correct one
           full_url = full_url.replace('<cloud_id>', cloud_id).replace('<user_id>', row[0])
           print("Executing url is: " + full_url)
           # Create request using cookie authentication
           response = requests.post(full_url, headers={'Cookie': "cloud.session.token=sfasfasdfadsfasETCETCETC.--"})
           print(response)
if __name__ == '__main__':
    main()

Suggest an answer

Log in or Sign up to answer