Disable a user via API in Jira

Fernando André October 22, 2019

Hello,

 

What is the process to disable a user via the API?

 

Thank you.

 

Best regards,

2 answers

1 accepted

0 votes
Answer accepted
Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 22, 2019

Hi @Fernando André , 

 

you can follow Atlassian documentation to disable a user with the API : https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-lifecycle-disable-post

 

Let me know if this helps, 

 

--Alexis

Fernando André October 22, 2019

Hello,

 

That's for the Cloud Jira, I'm using Server.

Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 22, 2019

Hi @Fernando André , 

 

this is the Server documentation : https://docs.atlassian.com/software/jira/docs/api/REST/8.3.0/#api/2/user-removeUser

Keep in mind that this features is only available from Jira 8.3.0

Fernando André October 22, 2019

Ok, unfortunately I'm still a bit behind. Thank you

Prasad Eda August 11, 2021

Hi @Alexis Robert ,

I need your help as am new to JIRA Cloud. 

Could you please explain the step-by-step process that how to disable bulk users via the API?

Regards,

Prasad

zaphnet August 26, 2021

Hi,

Running a Jira Server 8.13.6 I implemented a script that Disables the user, the script works fine, the commands get the responses OK and the "Active" state of the user is changed - every thing is fine there.

The strange thing is that when attempting to edit the Details of the User in the GUI - the "Deactivated Checkbox" is not ticked!

The user is inactive, and is not able to log in.

Appears to be a bug in the GUI? Will post question in forum also.

test2.PNG

RTFM: Everything works as expected - it says "Active" not "Deactivated"....

 

1 vote
Rafael Costa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2022

this is my python code to do it:

 

import urllib3
import requests
import json
from requests.auth import HTTPBasicAuth

url = f"https://yourdomain.com/rest/api/2/user"
auth = HTTPBasicAuth("user", "password")
headers = {"Accept": "application/json", "Content-Type": "application/json"}
params = {"username": "jack"}
payload = json.dumps( {"active": False} )
requests.request("PUT", url, data=payload, params=params, headers=headers, auth=auth, verify=False)
EdgeSync January 25, 2023

Thanks @Rafael Costa 

I spent a while toying with jira python library - but that got me no where. Your example worked perfectly for me on Jira Data Center 8.20. 

Appreciate it.

Suggest an answer

Log in or Sign up to answer