cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to pass 'Save as my default filter' via API or js?

Iryna
7 - Data Storage
7 - Data Storage

We are working on embedding Sisense as a part of our own application. One of the things we'd like to do is to allow users to save some filters for the future. 

I know that Sisense has this functionality `Save as my default filter` but our user testing has shown that users can not easily find it without extra guidance. Therefore we were hoping to do our own button or other interaction in our platform that would allow saving filters for that user. 

Iryna_0-1641453992025.png

I have tried searching for any reference in Sisense documentation, but no success so far. 

Did anyone do something similar? 🙂 

1 REPLY 1

harikm007
13 - Data Warehouse
13 - Data Warehouse

hi @Iryna ,

There is an API to update dashboard. You need to pass filters to be saved as json.

/dashboards/{id} - PATCH request

Refer this python script.

import json
import requests

server_name = 'https://XXXXXXX.XXXXXXX.com'

username = 'enter your user name'
password = 'Enter your password'

dashboardid = 'dashboard id'



login_url = server_name + '/api/v1/authentication/login'
dash_export_base_url = server_name + '/api/v1/dashboards/export?dashboardIds='

login_data = {  'username' : username,
                'password' : password
                }

login_res = requests.post(url=login_url, data=login_data).json()

access_token = login_res.get('access_token')
if len(access_token) > 0:
    print('login succesful.')
    
api_header = {'Authorization': 'Bearer ' + access_token, "Content-Type": "application/json"}

dash_file = requests.get(url=dash_export_base_url + dashboardid, headers=api_header, allow_redirects=True).json()

dash_filters = {
                "defaultFilters": dash_file[0].get("filters")}

update_dash_url = server_name + '/api/v1/dashboards/' + dashboardid
update_res = requests.patch(url=update_dash_url, headers=api_header, allow_redirects=True, json=dash_filters)
print('Filters Saved')
requests.get(server_name + '/api/v1/authentication/logout')

Thanks,

Hari