GitHub user xokok created a discussion: API returns empty dashboards/charts
(count:0) after successful login on Superset 4.1.2
I'm facing a critical issue on Superset 4.1.2 where I cannot retrieve any
Dashboard or Chart data via the REST API, even though the user has full admin
privileges and the UI works perfectly.
Environment
- Superset Version: 4.1.2
- Deployment: Direct installation on a virtual machine (Ubuntu)
- Auth type: Database auth
- User role: Admin
- Dashboard status: Published and visible in the UI
**Issue Description**
1. I can log in successfully via API /api/v1/security/login and get a valid JWT
token.
2. When calling /api/v1/dashboard/ or /api/v1/chart/, the response returns 200
OK but with empty data:
`{"count":0,"result":[]}`
3. The same user (apiuser) is an Admin and can view all published dashboards
normally in the web UI.
4. Charts API also returns empty result, same as dashboards.
**My Python Test Code:**
`
# -*- coding: utf-8 -*-
import requests
import json
requests.packages.urllib3.disable_warnings()
class SupersetApi(object):
def __init__(self):
self.host = '10.xxx.x.159'
self.port = 8088
self.base_url = 'https://%s:%s/api/v1' % (self.host, self.port)
self.token = None
self.session = requests.Session()
def login(self):
url = self.base_url + '/security/login'
data = {
"password": "password",
"provider": "db",
"refresh": True,
"username": "apiuser"
}
headers = {"Content-Type": "application/json"}
resp = self.session.post(url, data=json.dumps(data), headers=headers,
verify=False)
if resp.status_code == 200:
self.token = resp.json()['access_token']
print("login in successful")
def get_all_dashboards(self):
if not self.token:
self.login()
params = {
"q": '{"filters": [], "page_size": 100, "page": 0}'
}
url = self.base_url + '/dashboard/'
headers = {
"Authorization": "Bearer " + self.token,
"Content-Type": "application/json"
}
resp = self.session.get(url, headers=headers, params=params,
verify=False)
print("response status:", resp.status_code)
print("response data:", resp.text)
if __name__ == '__main__':
api = SupersetApi()
api.login()
api.get_all_dashboards()
`
**Facts**
- The user apiuser is assigned to the Admin role.
- At least one published dashboard exists and is visible in the UI.
- Login API works and returns a valid token.
- Dashboard API returns 200 OK but empty result (count: 0).
- Same result for Charts API.
**Expected behavior**
- Admin user should be able to list all dashboards via API like in the UI.
**Actual behavior**
- API returns empty data:
`{"count":0,"result":[]}`
Could anyone help me explain why the Admin user cannot get any dashboard/chart
data via REST API?Is this a known issue in version 4.1.2?
@dosubot
GitHub link: https://github.com/apache/superset/discussions/38814
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]