It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update User (Deactivate) using API

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

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.

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

You're welcome @Rafał Nowakowski :)

0 votes
miikhy Community Leader Aug 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

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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you