cancel
Showing results for 
Search instead for 
Did you mean: 

Use dashboard API to get data in python dataframe

aditya
7 - Data Storage
7 - Data Storage

I have a widget which displays users with points and I want to fetch top 10 users from that widget.Also I need to select current month "01/2025" from the filter.Let me know how this can be done

But I'm getting weired error.Please help!

I'm an admin so I have a token from my profile section.

 

 

import requests

url = "https://bp.sisense.com/api/v1/dashboards/4577fc4415dd7d003339bfdc/widgets/4577c7716dd7d554441bjae"


# authentication
headers = {
"Content-Type": "application/json",
"Authorization": "" }

# Send the request
response = requests.get(url, headers=headers)
response

# Check if the request was successful
data = response.json()
data

 

Error:

{'error': {'code': 5002,
  'message': 'Invalid token.',
  'status': 401,
  'httpMessage': 'unauthorized'}}

 

7 REPLIES 7

DRay
Community Team Leader
Community Team Leader

Hi @aditya,

Thank you for reaching out. I edited your post to remove potentially sensitive information.

It looks like the authorization token is to short. Can you make sure that it is copied correctly and let us know how it goes?

Thank you.

David Raynor (DRay)

aditya
7 - Data Storage
7 - Data Storage

@DRay , I have intentionally not provided the token,it is usually Bearer 'token' format

Thanks!

HamzaJ
12 - Data Integration
12 - Data Integration

The token has been removed, however do you use Bearer before the token? So "Authorization": "Bearer TOKEN"

AssafHanina
Sisense Team Member
Sisense Team Member

Hey @aditya ,

As mentioned by @HamzaJ , it's seems that the Bearer is missing from the Authorization. 
therefore, the error message is Unauthorized.

Please find an updated Sample script including the Bearer token 

 

import requests

# define Variables
server = '' #format of https://my-sisense.sisense.com
token = ''
dashboard_oid = ''
widget_oid = ''

### 
headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}
url = f'{server}/api/v1/dashboards/{dashboard_oid}/widgets/{widget_oid}'

# Send the request
response = requests.get(url=url, headers=headers)
print(response.status_code)

data = response.json()
print(data)

 

Best Regards

Assaf

aditya
7 - Data Storage
7 - Data Storage

@AssafHanina ,

I also tried in the format which you shared but I'm getting same error "Unauthorised".

Thanks!

AssafHanina
Sisense Team Member
Sisense Team Member

hey @aditya ,

Thanks for letting me know. 

@DRay - Please arrange for internal technical resources to provide assistance in this case.

Best regards

Assaf

DRay
Community Team Leader
Community Team Leader

Done

David Raynor (DRay)