Update User (Deactivate) using API

Rafał Nowakowski August 27, 2018

Hello, 

I use Jira Server 7.6.3, so i try to use this api: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/user-updateUser.

I want to make user Unactive.

First i get user info via browser: JIRAURL/rest/api/2/user?username=nowakor and copied all response.

{
"self": "JIRAURL/rest/api/2/user?username=xxx",
"key": "xxx",
"name": "xxx",
"emailAddress": "xxx@gmail.com",
"avatarUrls": {
"48x48": "JIRAURL/secure/useravatar?avatarId=10122",
"24x24": "JIRAURL/secure/useravatar?size=small&avatarId=10122",
"16x16": "JIRAURL/secure/useravatar?size=xsmall&avatarId=10122",
"32x32": "JIRAURLl/secure/useravatar?size=medium&avatarId=10122"
},
"displayName": "xxx [test]",
"active": true,
"timeZone": "Europe/Warsaw",
"locale": "pl_PL",
"groups": {
"size": 1,
"items": []
},
"applicationRoles": {
"size": 1,
"items": []
},
"expand": "groups,applicationRoles"
}

 

After that i did this PUT request:

{

"active":false,
"displayName": "xxx test2",
"emailAddress": "xxx2@gmail.com",
"active":false,

}

 

Name and email has changed but active status hasn't. Do you have any solutions?

2 answers

1 accepted

1 vote
Answer accepted
Arun_Thundyill_Saseendran
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.
August 28, 2018

The workaround to it is in the get request expand groups and remove the user from all the groups. Especially the JIRA software users groups. With this, the user cannot login and also will not consume a license. 

This is the best alternative that worked for me via script.

Let me know if you have any queries.

If this solution works for you, please accept the answer so that it will be helpful for others in the community.

Rafał Nowakowski August 30, 2018

Yeah, this soulution sounds really great for me especially when my mian goal is to reduce unactive users that use license.

 

Thanks @Arun_Thundyill_Saseendran

Arun_Thundyill_Saseendran
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.
August 30, 2018

You're welcome @Rafał Nowakowski :)

0 votes
miikhy
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.
August 27, 2018

Hi there,

If you look at the scheme for the updateUser endpoint (request scheme) there is no mention of the active flag, which explains why you can't use it. As of now, deactivating a user through the API is not yet possible, it's tracked here: https://jira.atlassian.com/browse/JRASERVER-44801

My suggestion would be to vote for it and watch it. If you're handy with scripts, you could leverage ScriptRunner Script REST Endpoint to build your own (https://scriptrunner.adaptavist.com/latest/jira/rest-endpoints.html).

Best luck with either option!

Cheers

Gustavo Chaves January 14, 2020

The https://jira.atlassian.com/browse/JRASERVER-44801 issue was fixed on Jira 8.3.0. Now you can deactivate users using the standard API.

Suggest an answer

Log in or Sign up to answer