Resend Invitations to Inactive Users in Bulk
Steps:
1) Download Python and install it on your PC or the Sisense machine (make sure to add python to the PATH to easily initiate installation of directories).
2) Run CMD and type the following commands to add libraries used as part of our solution:
- pip install requests
- pip install json
- pip install requests
- pip install json
3) Create a .py file and add the following script to it:
import requests
import json
username = '[email protected]' #replace with an admin user's user name
password = 'password' #replace with an admin user's password
Sisense_url = 'http://localhost:8081' #replace with your Sisense url
# Get Auth token
url = Sisense_url+"/api/v1/authentication/login"
payload = "username="+username.replace('@','%40')+"&password="+password
headers = {
'content-type': "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)
auth_token = response.json()["access_token"]
auth_token = "Bearer " + auth_token
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': auth_token
}
url = Sisense_url + '/api/v1/users'
resendUrl = Sisense_url + '/api/v1/account/begin_activate'
response = requests.request("GET", url, headers=headers)
users = response.json()
#Sending invites for inactive users
total = 0
for item in users:
active = item["active"]
if not active:
email = item["email"]
payload = '{"email": ' +'"'+email+'"}'
response = requests.request("POST", resendUrl, data=payload, headers=headers)
print(item["email"])
total = total+1
print(total)
4) This process can be automated using a Windows Task Scheduler as well.
That's it!
Updated 02-16-2024
intapiuser
Admin
Joined December 15, 2022