Sharing All System's Dashboards With A Specific User
Sometimes, for example when adding a new admin user, you might want to share all of the dashboards in the system with that user.
In order to do that, you can use the following Python script:
import requests
import time
import json
user_name = '[email protected]' #Change to your admin user name.
password = 'Sisense' #Change to your password.
Sisense_url = "http://localhost:8081" #Change to your Sisense address.
new_admin = "[email protected]" #Change to your new admin user name.
user_rule = "edit" # change to "view" if the user is a viewer. If it is a designer ir admin, leave it as it is.
#------------------------------------------------------------------------------
# Get auth_token
url = Sisense_url+"/api/v1/authentication/login"
payload = "username="+user_name.replace('@','%40')+"&password="+password
headers = {
'cache-control': "no-cache",
'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
# Get user
url = Sisense_url + "/api/v1/users"
headers = {
'accept': "application/json",
'authorization': auth_token
}
response = requests.request("GET", url, headers=headers)
response = response.json()
user_id = ''
for user in response:
try:
if user["userName"] == new_admin:
user_id = user["_id"]
except KeyError:
pass
# Get all dashboards
url = Sisense_url + "/api/v1/dashboards/admin"
headers = {
'accept': "application/json",
'authorization': auth_token
}
response = requests.request("GET", url, headers=headers)
response = response.json()
# Share all dashboards with user
new_admin_share = {
"shareId": user_id,
"type": "user",
"rule": "view",
"subscribe": False
}
#new_admin_share = json.dumps(new_admin_share)
for dashboard in response:
dashboard_share = dashboard["shares"]
dashboard_share.append(new_admin_share)
dashboard_share = {"shares": dashboard_share}
payload = json.dumps(dashboard_share)
#print dashboard_share
url = Sisense_url + "/api/v1/dashboards/"+dashboard["oid"]
headers = {
'accept': "application/json",
'content-type': "application/json",
'accept': "application/json",
'authorization': auth_token
}
response = requests.request("PATCH", url, data=payload, headers=headers)
if response.status_code == 200:
print "dashboard was shared with "+new_admin
print "Done!"
In order to use it, please make sure you have the following installed on your system:
- Python 2.7 (64-bit)
- The following Python libraries: requests, time, json
Also, adjust the parameters at the beginning of the script (above the dashed line) to yours:

Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022