You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Ametist2502 (via GitHub)" <gi...@apache.org> on 2025/10/27 10:16:00 UTC

[D] Issue when trying get dataset using API [superset]

GitHub user Ametist2502 created a discussion: Issue when trying get dataset using API

**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!

GitHub link: https://github.com/apache/superset/discussions/35855

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "Ametist2502 (via GitHub)" <gi...@apache.org>.
GitHub user Ametist2502 added a comment to the discussion: Issue when trying get dataset using API

This is my script.
session = requests.Session()

headers = {
    "Authorization": "Bearer <token>",
    "X-CSRFToken": "<token>",
    "Cookie": "session=<session_key>"
}

response = session.request(method, prod_get_dataset_url, headers=headers)
print(response.content)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792110

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Issue when trying get dataset using API

<!-- Answer -->
If your Python script returns `count = 0` but Swagger UI shows datasets, it's almost always due to a difference in authentication/session context or user permissions. Superset requires the correct session cookie, CSRF token, and Authorization header for API access—if any are missing or mismatched, the API will silently return zero results, even for admin users [example](https://github.com/apache/superset/issues/23352).

Make sure:
- The user account used in your Python script has the same roles and dataset access as the one in Swagger UI.
- You let `requests.Session()` manage cookies automatically and do not manually set the Cookie header.
- The Authorization header is present for all requests, including CSRF token retrieval [example](https://github.com/apache/superset/issues/32257).

If all of this checks out, compare the full request headers and cookies between Swagger UI (using browser dev tools) and your Python code. Even a small difference can cause Superset to filter out all datasets [discussion](https://github.com/apache/superset/discussions/35802).

Also, check if your organization uses custom RBAC or security manager settings that might affect API results. If you still get empty results, try logging in via the browser, copying the session cookie, and using it in your Python request as a test—if that works, it's definitely a session/cookie issue [example](https://github.com/apache/superset/issues/23352).

Let me know if you want help comparing request details or debugging user permissions.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=90d11429-adca-4c42-855b-4a2bdf6a937b) [![Ask Dosu about superset](https://img.shields.io/badge/Ask%20Dosu%20about%20superset-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS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3OTE5SDQwLjcwNFY3LjYxNTMyWiIgZmlsbD0iYmxhY2siIG1hc2s9InVybCgjZG9zdS1kLWN1dG91dCkiLz48cGF0aCBkPSJNNjguOTIxNSAzNi4wMTM1QzY4LjkyMTUgMzYuMDEzNSA2NS43MzY5IDQ5LjQ3MzggNTEuNDIzMSA0OS40NzM4QzM3LjEwOTMgNDkuNDczOCAzMi41Nzg3IDM3LjM1OTYgMzIuNTc4NyAzNi4wMTM1IiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjcuNjkxNjEi
 IHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [![Share Dosu with your team](https://img.shields.io/badge/Share%20Dosu%20with%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792379

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Issue when trying get dataset using API

<!-- Answer -->
If your Python script returns `count = 0` but Swagger UI shows datasets, it's almost always due to a difference in authentication/session context or user permissions. Superset requires the correct session cookie, CSRF token, and Authorization header for API access—if any are missing or mismatched, the API will silently return zero results, even for admin users [example](https://github.com/apache/superset/issues/23352).

Make sure:
- The user account used in your Python script has the same roles and dataset access as the one in Swagger UI.
- You let `requests.Session()` manage cookies automatically and do not manually set the Cookie header.
- The Authorization header is present for all requests, including CSRF token retrieval [example](https://github.com/apache/superset/issues/32257).

If all of this checks out, compare the full request headers and cookies between Swagger UI (using browser dev tools) and your Python code. Even a small difference can cause Superset to filter out all datasets [discussion](https://github.com/apache/superset/discussions/35802).

Also, check if your organization uses custom RBAC or security manager settings that might affect API results. If you still get empty results, try logging in via the browser, copying the session cookie, and using it in your Python request as a test—if that works, it's definitely a session/cookie issue [example](https://github.com/apache/superset/issues/23352).

Let me know if you want help comparing request details or debugging user permissions.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/90d11429-adca-4c42-855b-4a2bdf6a937b?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35855)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792379

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "Ametist2502 (via GitHub)" <gi...@apache.org>.
GitHub user Ametist2502 added a comment to the discussion: Issue when trying get dataset using API

i run script you give me but response of it return like below
{'count': 0, 'description_columns': {}, 'ids': [], 'label_columns': {'catalog': 'Catalog', 'changed_by.first_name': 'Changed By First Name', 'changed_by.id': 'Changed By Id', 'changed_by.last_name': 'Changed By Last Name', 'changed_by_name': 'Changed By Name', 'changed_on_delta_humanized': 'Changed On Delta Humanized', 'changed_on_utc': 'Changed On Utc', 'database.database_name': 'Database Database Name', 'database.id': 'Database Id', 'datasource_type': 'Datasource Type', 'default_endpoint': 'Default Endpoint', 'description': 'Description', 'explore_url': 'Explore Url', 'extra': 'Extra', 'id': 'Id', 'kind': 'Kind', 'owners.first_name': 'Owners First Name', 'owners.id': 'Owners Id', 'owners.last_name': 'Owners Last Name', 'schema': 'Schema', 'sql': 'Sql', 'table_name': 'Table Name', 'uuid': 'Uuid'}, 'list_columns': ['id', 'database.id', 'database.database_name', 'changed_by_name', 'changed_by.first_name', 'changed_by.last_name', 'changed_by.id', 'changed_on_utc', 'changed_on_delta_hum
 anized', 'default_endpoint', 'description', 'datasource_type', 'explore_url', 'extra', 'kind', 'owners.id', 'owners.first_name', 'owners.last_name', 'catalog', 'schema', 'sql', 'table_name', 'uuid'], 'list_title': 'List Sqla Table', 'order_columns': ['table_name', 'catalog', 'schema', 'changed_by.first_name', 'changed_on_delta_humanized', 'database.database_name'], 'result': []}

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792312

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Issue when trying get dataset using API

<!-- Answer -->
The main issue is that you're manually setting the Cookie header while also using requests.Session(). This can override or conflict with the session's internal cookie handling, which often leads to authentication problems and causes Superset to return count = 0 as a security measure [example](https://github.com/apache/superset/issues/34548).

Instead, let requests.Session() manage cookies automatically. Here’s a recommended flow:

```python
import requests

session = requests.Session()

# 1. Login to get the access token (and set initial cookies)
login_resp = session.post(
    "https://your-superset/api/v1/security/login",
    json={"username": "your_user", "password": "your_pass", "provider": "db"}
)
access_token = login_resp.json()["access_token"]
session.headers.update({"Authorization": f"Bearer {access_token}"})

# 2. Get CSRF token (session will handle cookies)
csrf_resp = session.get("https://your-superset/api/v1/security/csrf_token/")
csrf_token = csrf_resp.json()["result"]
session.headers.update({"X-CSRFToken": csrf_token})

# 3. Call the dataset API (no need to set Cookie header manually)
resp = session.get("https://your-superset/api/v1/dataset/")
print(resp.json())
```

Make sure you use the same session object for all steps so cookies and headers persist. Do not set the Cookie header manually—let the session handle it. This approach matches what Swagger UI does in the browser and should return the expected datasets [reference](https://github.com/apache/superset/issues/34548).

If you still get count = 0, double-check that your user has dataset access and compare your request headers/cookies to those in Swagger UI using browser dev tools.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=bd982e5b-767e-467a-b26f-97bd32bd470c) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS4yOTIzNiAxMi43OTI4TDE3Ljc1OTMgNi42ODE4OFY3Mi41NjY3TDUuMjkyMzYgODQuMDYxOFYxMi43OTI4WiIgZmlsbD0iI0I0QkI5MSIvPjxwYXRoIGQ9Ik0xOC4yNTc1IDczLjExOTZMNTkuMTMyOSA3Mi43NDhMNTEuNzAxMSA4Mi40MDk1TDI5LjAzMzggODYuMjkxTDYuMjM5NjIgODUuMTU1NEwxOC4yNTc1IDczLjExOTZaIiBmaWxsPSIjNzc4NTYxIi8%2BPHBhdGggZD0iTTE3LjQ5MTYgMy43MzYzM0wzLjU4NTU3IDEyLjcwOTlWODMuNTc5MkMzLjU4NTU3IDg0Ljc1NDIgNC4
 5ODU2MyA4NS4zNjUyID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ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792196

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Issue when trying get dataset using API

<!-- Answer -->
If you're still getting `count = 0` even after passing the CSRF token and cookies from `/security/csrf-token`, it's likely that your Python request is missing the Authorization header with a valid Bearer token, or the session context isn't matching what Swagger UI/browser uses. Superset's API requires all three: the Authorization header, session cookies, and CSRF token. If any are missing or don't match, Superset's security layer will silently filter out all datasets and return `count = 0` as a security feature, instead of an error [see code reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/datasets/api.py).

Double-check that:
- You're including the `Authorization: Bearer <access_token>` header in both the CSRF token request and the dataset request [see example](https://github.com/apache/superset/issues/32257).
- You're using a persistent session (like `requests.Session()`) to maintain cookies across requests.
- All cookies and the CSRF token from the `/security/csrf-token` response are included in the `/api/v1/dataset` request.

If all of these are correct, compare the full request headers and cookies between your browser (Swagger UI) and your Python code to spot any differences. Even a small mismatch can cause Superset to treat the session as unauthorized and return zero results.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=5970bbce-0190-4dde-a44e-d9c06f5e8b8c) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS4yOTIzNiAxMi43OTI4TDE3Ljc1OTMgNi42ODE4OFY3Mi41NjY3TDUuMjkyMzYgODQuMDYxOFYxMi43OTI4WiIgZmlsbD0iI0I0QkI5MSIvPjxwYXRoIGQ9Ik0xOC4yNTc1IDczLjExOTZMNTkuMTMyOSA3Mi43NDhMNTEuNzAxMSA4Mi40MDk1TDI5LjAzMzggODYuMjkxTDYuMjM5NjIg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LjM1OTYgMzIuNTc4NyAzNi4wMTM1IiBzdHJva2U9ImJsYWNrIiB
 zdHJva2Utd2lkdGg9IjcuNjkxNjEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792076

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Issue when trying get dataset using API

<!-- Answer -->
The main issue is that you're manually setting the Cookie header while also using requests.Session(). This can override or conflict with the session's internal cookie handling, which often leads to authentication problems and causes Superset to return count = 0 as a security measure [example](https://github.com/apache/superset/issues/34548).

Instead, let requests.Session() manage cookies automatically. Here’s a recommended flow:

```python
import requests

session = requests.Session()

# 1. Login to get the access token (and set initial cookies)
login_resp = session.post(
    "https://your-superset/api/v1/security/login",
    json={"username": "your_user", "password": "your_pass", "provider": "db"}
)
access_token = login_resp.json()["access_token"]
session.headers.update({"Authorization": f"Bearer {access_token}"})

# 2. Get CSRF token (session will handle cookies)
csrf_resp = session.get("https://your-superset/api/v1/security/csrf_token/")
csrf_token = csrf_resp.json()["result"]
session.headers.update({"X-CSRFToken": csrf_token})

# 3. Call the dataset API (no need to set Cookie header manually)
resp = session.get("https://your-superset/api/v1/dataset/")
print(resp.json())
```

Make sure you use the same session object for all steps so cookies and headers persist. Do not set the Cookie header manually—let the session handle it. This approach matches what Swagger UI does in the browser and should return the expected datasets [reference](https://github.com/apache/superset/issues/34548).

If you still get count = 0, double-check that your user has dataset access and compare your request headers/cookies to those in Swagger UI using browser dev tools.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bd982e5b-767e-467a-b26f-97bd32bd470c?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35855)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792196

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Issue when trying get dataset using API

<!-- Greeting -->
Hi @Ametist2502! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.

<!-- Answer -->
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:

1. Use a requests.Session() object to persist cookies across requests.
2. After logging in and getting the access token, save all cookies set by the server.
3. When calling /api/v1/dataset, include:
   - The Authorization header: `Bearer <access_token>`
   - The CSRF token in the `X-CSRFToken` header (if required)
   - All cookies from the login and CSRF requests

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](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/datasets/api.py), [security details](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/api.py)).

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.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=eeb9e1c0-a562-47f0-9149-e7decfa95ee2) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS4yOTIzNiAxMi43OTI4TDE3Ljc1OTMgNi42ODE4OFY3Mi41NjY3TDUuMjkyMzYgODQuMDYxOFYxMi43OTI4WiIgZmlsbD0iI0I0QkI5MSIvPjxwYXRoIGQ9Ik0xOC4yNTc1IDczLjExOTZMNTkuMTMyOSA3Mi43NDhMNTEuNzAxMSA4Mi40MDk1TDI5LjAzMzggODYuMjkxTDYuMjM5NjIgODUuMTU1NEwxOC4yNTc1IDczLjExOTZaIiBmaWxsPSIjNzc4NTYxIi8%2BPHBhdGggZD0iTTE3LjQ5MTYgMy43MzYzM0wzLjU4NTU3IDEyLjcwOTlWODMuN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ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14791874

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Issue when trying get dataset using API

<!-- Greeting -->
Hi @Ametist2502! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.

<!-- Answer -->
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:

1. Use a requests.Session() object to persist cookies across requests.
2. After logging in and getting the access token, save all cookies set by the server.
3. When calling /api/v1/dataset, include:
   - The Authorization header: `Bearer <access_token>`
   - The CSRF token in the `X-CSRFToken` header (if required)
   - All cookies from the login and CSRF requests

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](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/datasets/api.py), [security details](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/api.py)).

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.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/eeb9e1c0-a562-47f0-9149-e7decfa95ee2?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35855)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14791874

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Issue when trying get dataset using API

<!-- Answer -->
If you're still getting `count = 0` even after passing the CSRF token and cookies from `/security/csrf-token`, it's likely that your Python request is missing the Authorization header with a valid Bearer token, or the session context isn't matching what Swagger UI/browser uses. Superset's API requires all three: the Authorization header, session cookies, and CSRF token. If any are missing or don't match, Superset's security layer will silently filter out all datasets and return `count = 0` as a security feature, instead of an error [see code reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/datasets/api.py).

Double-check that:
- You're including the `Authorization: Bearer <access_token>` header in both the CSRF token request and the dataset request [see example](https://github.com/apache/superset/issues/32257).
- You're using a persistent session (like `requests.Session()`) to maintain cookies across requests.
- All cookies and the CSRF token from the `/security/csrf-token` response are included in the `/api/v1/dataset` request.

If all of these are correct, compare the full request headers and cookies between your browser (Swagger UI) and your Python code to spot any differences. Even a small mismatch can cause Superset to treat the session as unauthorized and return zero results.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5970bbce-0190-4dde-a44e-d9c06f5e8b8c?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35855)

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792076

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Issue when trying get dataset using API [superset]

Posted by "Ametist2502 (via GitHub)" <gi...@apache.org>.
GitHub user Ametist2502 added a comment to the discussion: Issue when trying get dataset using API

when i passing CSRF and Cookies got from header when call API /security/csrf-token it still return count = 0

GitHub link: https://github.com/apache/superset/discussions/35855#discussioncomment-14792033

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org