You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to Generate a Filtered Screenshots of Dashboard Charts #32037
Originally posted by juliacebria January 30, 2025
I have a dashboard with multiple charts, each showing data for different counties. I need to generate a PDF for each county with the relevant filtered data.
If generating a filtered PDF is not possible, I want to capture a screenshot of each chart individually with the county filter applied. However, when using GET /api/v1/chart/{pk}/cache_screenshot/, the API does not allow filtering.
Is there a way to pass filters when generating a screenshot via API, or an alternative method to schedule or generate a filtered PDF of the dashboard?
Hello @juliacebria! I'm here to help you with any bugs, questions, or contributions you have.
There is a way to pass filters when generating a screenshot via the API in Apache Superset. You can use the DownloadScreenshot component, which utilizes the dataMask from the Redux state to include the current filter state of the dashboard. This dataMask is part of the jsonPayload in the POST request to the /api/v1/dashboard/${dashboardId}/cache_dashboard_screenshot/ endpoint, ensuring that the screenshot reflects the current filters applied to the dashboard [1].
Additionally, you can generate a PDF of the dashboard with the applied filters. The process involves caching the screenshot and then retrieving it in PDF format using functions like cache_dashboard_screenshot and build_pdf_from_screenshots, which ensure that the PDF reflects the current state of the dashboard, including any filters [2].
A 404 Not Found response when accessing the /api/v1/dashboard/{dashboard_id}/cache_dashboard_screenshot/ endpoint can occur for several reasons:
Dashboard Not Found: Ensure that the dashboard_id (in your case, 2) corresponds to an existing dashboard. If the dashboard does not exist, a 404 response will be returned [1].
Feature Flags Disabled: The endpoint requires the THUMBNAILS and ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS feature flags to be enabled. If either of these flags is disabled, the endpoint will return a 404 response [1].
Incorrect Payload Structure: The payload structure you are using seems incorrect. The expected payload should be a JSON object with the following structure:
The cache_key I received from a previous API call is bed09521aa9f663df42b625577cff7b5. I correctly replace {cache_key} with the actual value, but I still get the 404 Not Found error, with the following response:
A 404 Not Found error when trying to retrieve a cached screenshot using the cache_key can occur for a couple of reasons:
Dashboard Does Not Exist: Ensure that the dashboard with the specified ID (in your case, 2) actually exists. If the dashboard does not exist, a 404 response will be returned.
Screenshot Not in Cache: Even if the dashboard exists, the screenshot might not be available in the cache. The cache might not have been set correctly, or it might have expired or been cleared.
Make sure that the cache_key is valid and that the cache is properly configured and operational. If the cache key was set with a timeout, it might have expired, leading to the screenshot not being found in the cache [1].
@dosu
I am able to successfully post to the cache dashboard screenshot API endpoint (/api/v1/dashboard/2/cache_dashboard_screenshot/) and receive a 202 Accepted status with a valid cache_key in the response.
However, when I try to fetch the screenshot using the generated cache_key with the following endpoint:
GET http://localhost:8088/api/v1/dashboard/2/screenshot/{cache_key}/
I get a 404 Not Found error with the response message "Not found", even though the dashboard exists and the cache key seems correct.
A 404 when retrieving a dashboard screenshot with a cache key usually means the screenshot isn't available in the cache yet. This can happen if the async screenshot task hasn't finished, if the cache is misconfigured, or if there was an error during screenshot generation. Here’s what you can check:
Wait a few seconds after POSTing to /cache_dashboard_screenshot/ before trying the GET, since screenshot generation is async and handled by Celery.
Check your Superset and Celery logs for errors or warnings related to screenshot generation or caching—look for issues with WebDriver, cache backend, or task failures.
Make sure both the THUMBNAILS and ENABLE_DASHBOARD_SCREENSHOT_ENDPOINTS feature flags are enabled, and that your THUMBNAIL_CACHE_CONFIG is set to a real cache backend (like Redis or Memcached), not NullCache.
Confirm your cache timeout and error TTL settings are reasonable, so screenshots don’t expire before you fetch them.
Double-check that your cache key parameters (dashboard state, window size, thumb size, permalink key) match between POST and GET requests—any mismatch can cause a cache miss and a 404.
If the cache is not set or misconfigured, screenshot generation will be skipped and retrieval will always fail with a 404. If there’s a WebDriver or screenshot error, the cache payload will be in ERROR status and not retrievable until the error TTL expires. All of this is by design in the Superset screenshot API logic (source, source, source).
Activity
dosubot commentedon Jan 30, 2025
Hello @juliacebria! I'm here to help you with any bugs, questions, or contributions you have.
There is a way to pass filters when generating a screenshot via the API in Apache Superset. You can use the
DownloadScreenshotcomponent, which utilizes thedataMaskfrom the Redux state to include the current filter state of the dashboard. ThisdataMaskis part of thejsonPayloadin the POST request to the/api/v1/dashboard/${dashboardId}/cache_dashboard_screenshot/endpoint, ensuring that the screenshot reflects the current filters applied to the dashboard [1].Additionally, you can generate a PDF of the dashboard with the applied filters. The process involves caching the screenshot and then retrieving it in PDF format using functions like
cache_dashboard_screenshotandbuild_pdf_from_screenshots, which ensure that the PDF reflects the current state of the dashboard, including any filters [2].To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
dosubot commentedon Jan 30, 2025
A 404 Not Found response when accessing the
/api/v1/dashboard/{dashboard_id}/cache_dashboard_screenshot/endpoint can occur for several reasons:Dashboard Not Found: Ensure that the
dashboard_id(in your case,2) corresponds to an existing dashboard. If the dashboard does not exist, a 404 response will be returned [1].Feature Flags Disabled: The endpoint requires the
THUMBNAILSandENABLE_DASHBOARD_SCREENSHOT_ENDPOINTSfeature flags to be enabled. If either of these flags is disabled, the endpoint will return a 404 response [1].Incorrect Payload Structure: The payload structure you are using seems incorrect. The expected payload should be a JSON object with the following structure:
{ "dataMask": {}, "activeTabs": [], "anchor": "", "urlParams": [] }Ensure that your payload matches this structure. The
dataMaskshould be directly within the main JSON object, not nested underjsonPayload[1][2].Please verify these aspects to resolve the 404 error.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
juliacebria commentedon Jan 30, 2025
Thank you! That worked and now I get Status Code: 202 and the cache_key.
No obstant, I'm encountering a 404 Not Found error when trying to retrieve a cached screenshot using the following API endpoint:
GET http://localhost:8088/api/v1/dashboard/2/screenshot/{cache_key}/
The cache_key I received from a previous API call is bed09521aa9f663df42b625577cff7b5. I correctly replace {cache_key} with the actual value, but I still get the 404 Not Found error, with the following response:
{
"message": "Not found"
}
dosubot commentedon Jan 30, 2025
A 404 Not Found error when trying to retrieve a cached screenshot using the cache_key can occur for a couple of reasons:
Dashboard Does Not Exist: Ensure that the dashboard with the specified ID (in your case,
2) actually exists. If the dashboard does not exist, a 404 response will be returned.Screenshot Not in Cache: Even if the dashboard exists, the screenshot might not be available in the cache. The cache might not have been set correctly, or it might have expired or been cleared.
Make sure that the cache_key is valid and that the cache is properly configured and operational. If the cache key was set with a timeout, it might have expired, leading to the screenshot not being found in the cache [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
juliacebria commentedon Jan 30, 2025
@dosu
I am able to successfully post to the cache dashboard screenshot API endpoint (/api/v1/dashboard/2/cache_dashboard_screenshot/) and receive a 202 Accepted status with a valid cache_key in the response.
However, when I try to fetch the screenshot using the generated cache_key with the following endpoint:
I get a 404 Not Found error with the response message "Not found", even though the dashboard exists and the cache key seems correct.
grc-harsh-agarwal commentedon Jul 24, 2025
@dosu
dosubot commentedon Jul 24, 2025
A 404 when retrieving a dashboard screenshot with a cache key usually means the screenshot isn't available in the cache yet. This can happen if the async screenshot task hasn't finished, if the cache is misconfigured, or if there was an error during screenshot generation. Here’s what you can check:
If the cache is not set or misconfigured, screenshot generation will be skipped and retrieval will always fail with a 404. If there’s a WebDriver or screenshot error, the cache payload will be in ERROR status and not retrievable until the error TTL expires. All of this is by design in the Superset screenshot API logic (source, source, source).
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.