Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to delete users using jira rest api

Hey,

I saw in the documentation this method https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/#api/2/user-removeUser but It doesn't work for me. 

I've tried to send the relevant accountId and as GET method I do get the relevant user but it doesn't work when I try to delete it.

 

Thanks in advance!

1 answer

0 votes
Charlie Misonne Community Leader May 31, 2021

Hi Yuval,

Do you get a response from the server when executing the delete method? If so, what's the message and what's the response code?

If you use curl please share your command so we can troubleshoot it or share a screenshot from your Postman or any tool you might be using.

Hey @Charlie Misonne 

I'm using postman+JS but I first started with postman in order to see that actually works before iterating through all the users.

This is the GET which does respond correctly: image.png

But when I try to delete it: 

image.png
it doesn't show anything and it didn't delete the user.

In addition I used the following script to delete projects and it did work ( even if the post man delete method didn't show any response):


axios
.get(
session_url,
{ auth: {
username: '****',
password: '*****'},

}
)
.then(function (response) {
let res= response.data;
let idArr=new Array();
for(var key in res){
idArr.push(res[key]['id']);

}
console.log(idArr);
for(var id in idArr){

axios.delete(
session_url+'/'+idArr[id],
{ auth: {
username: '*****',
password: '*****'},

}
)


;

}
});

Charlie Misonne Community Leader May 31, 2021

Ok, I can see a first reason already.

You were looking at the documentation for Jira SERVER and not for Jira Cloud which you seem to be using.

Cloud and Server do not share exactly the same REST endpoints.

Here is the documentation for Cloud: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete

The endpoint is /rest/api/3/user. 3 instead of 2. Can you try changing that and test again?

You also need to be a site administrator but I assume you are.

Hey thank you for the quick response, It didn't work either. 

Charlie Misonne Community Leader May 31, 2021

Well that's odd. In your screenshot I see you get a 204 response and that should mean the user was removed successfully.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Asked in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

284 views 14 14
View question

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