Issue when trying get dataset using API #35855
Replies: 1 comment 6 replies
-
|
Hi @Ametist2502! I'm Dosu and I’m helping the superset team. This usually happens when the Python requests session is missing some authentication context that Swagger UI handles automatically. For the /api/v1/dataset endpoint, Superset requires not just the access token, but also the correct session cookies and, in some cases, the CSRF token—even for GET requests, depending on your configuration. Swagger UI uses your browser's session, so it always has the right cookies and tokens. With Python requests, you need to make sure you:
If any of these are missing or mismatched, Superset will treat your session as unauthorized or lacking permissions, and the dataset query will be filtered down to zero results by the security layer (see code reference, security details). Double-check that your Python requests code is copying all cookies and headers from the login and CSRF steps into the dataset request. If you’re already doing this, compare the request details (headers, cookies, query params) between Swagger UI (using browser dev tools) and your Python code to spot any differences. That should help you get matching results. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I’m having an issue when calling the GET /api/v1/dataset endpoint.
When I run it on Swagger UI, it works correctly and returns data.
However, when I call it using Python’s requests library, the API response shows count = 0.
Steps to Reproduce
Call the login API to get the access token
Call the CSRF API to get the CSRF token and cookies
Call /api/v1/dataset using the GET method
Expected Behavior
The API should return the same dataset result as when called from Swagger UI.
Actual Behavior
The API call returns count = 0.
Environment
Superset version: 4.1.3
Python version: 3.9
Additional Context
Any help would be appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions