Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to use API token in python script

Balaji Shinde
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 5, 2020

Hello all,

I need to disable 900 Atlassian cloud users, I followed https://developer.atlassian.com/cloud/admin/user-management/rest/#api-users-account-id-manage-lifecycle-disable-post

I generated the API token for myself and using in a python script to test it, but I am getting error "{"code":401,"message":"Unauthorized"}". I have site admin access as well as directory admin access. I am able to disable the users via Atlassian portal. My token is also showing as valid in portal.

My code:

import requests
import json

url = "https://api.atlassian.com/users/FirstName.LastName@MyCompany.com/manage/lifecycle/disable"

headers = {
"Content-Type": "application/json",
"Authorization": "Bearer MyApiToken"
}

payload = json.dumps( {
"message": "Disabling Users who have left Company"
} )

response = requests.request(
"POST",
url,
data=payload,
headers=headers
)

print(response.text)

1 answer

0 votes
Nic Brough -Adaptavist-
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 Champions.
March 10, 2021

We cannot, we are not your admins.

Please ask your administrators.

dh0_kang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 10, 2021

who is my  administrators? can you give me a email address of  administrators?

Nic Brough -Adaptavist-
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 Champions.
March 11, 2021

No, we know nothing about your systems, we're a community of people here to talk Atlassian.

Your best bet is to ask the people around you, maybe the ones who asked you to use Jira, or the one who got you your account.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events