Trying to call REST API to remove a user.

Reuben deVries March 15, 2021

I'm trying to create a python script that will deactivate a jira user if they have left our employment. I'm trying to call the Jira cloud REST API but when I call the users/email?accountId I get returned a 404 error, it's specifically odd because I start off the fuction with a call that lists all the users, then I pull that data into a for loop which will start using the accountID and I don't get a 404 error there... what am I doing wrong?

here is a github gist to show you what I'm trying to accomplish... hopefully it helps...

https://gist.github.com/reubendevries-cta/1b1edf6000ad10278e15ac8173e745a3

1 answer

0 votes
carlosughini
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 15, 2021

Hi Reuben,

Welcome to the community! I hope you are having a nice day.

I'm not able to completely test your script, but from what it seems, I believe that the issue might be associated with the URL.

You can check the documentation here.

Please correct me in case I'm wrong, but apparently, you are building the URL like the following:

https://organizationspace.atlassian.net/rest/api/3/ + users/email + params

However, instead of users/email, the right format would be something like the following:

https://organizationspace.atlassian.net/rest/api/3/user? + accountId=

Could you please check the documentation and give it a try and let us know how it goes?

Looking forward to hearing from you.

Regards,

Carlos 

Reuben deVries March 15, 2021

Hi @carlosughini ,

Thanks for the reply. Your looking at the delete user call. At this exact moment I want the person's email - eventually after I've matched the email address (which I will be passing through a python argument parse command), then I will use the delete curl request command a bit lower down in the function (I've yet to complete that part) . The reason for this is that a person's email is usually a pretty good unique identifier across multiple different platforms (O365, AWS, GitLab, and Atlassian) that we utilize. I hope this helps you understand my process. That being said if you look at the params section in the requests: http for humans documentation it will automatically append the "?" to the query portion of the API call.

carlosughini
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2021

Hi Reuben,

Are you still facing this issue?

Could you please get one specific use as an example and try to perform the request maybe using postman or the terminal by using the accountId?

I understand that using an email address is easier, however, some changes were made, for privacy reasons, which removed certain details that used to work on API calls. The E-mail address is one of them, so I think if you could try the request directly via postman or terminal and using one user as an example you could confirm if the issue is in the script, params or even the endpoint.

Looking forward to hearing from you.

Reuben deVries March 17, 2021

@carlosughiniI'll look at it tomorrow morning, my workday is done for the day- so from what I am understanding from you the API call to grab the user's email address is no longer valid? That's disappointing... I guess I could try add another parameter in my script and user the username...

Reuben deVries March 18, 2021

@carlosughinicould you clarify a bit further here... what I am doing is created a python script that will deactivate a user if they leave our company. Which parameter do you suggest I pass through to the python script. Using the very specific account guid wouldn't make sense because if I have to manually look that up, I might as well deactivate them from the console - bypassing any need for the script. It seems like Atlassian broke a major functionality of the API, without really thinking about it and just said it was for privacy... can you explain further...

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events