GitHub user dosubot[bot] added a comment to the discussion: Warm up charts cache via API
<!-- Answer --> Yes, you can create a chart with `query_context` in a **single API call** — no need to create first and update later. The [ChartPostSchema](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py#L167-L226) accepts [`query_context` as an optional field](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py#L86-L90) during chart creation: ```python POST /api/v1/chart/ { "slice_name": "My Chart", "datasource_id": 1, "datasource_type": "table", "viz_type": "table", "params": "{...}", # your form_data as JSON string "query_context": "{...}" # your query_context as JSON string } ``` So your workflow can be: 1. Build your `params` (form_data) and `query_context` JSON strings 2. Create the chart with both in one POST request 3. Then `warm_up_cache` will work immediately since `query_context` is already stored <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d9159e46-5328-47 d3-90da-9a40d97eb8d5?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/d9159e46-5328-47d3-90da-9a40d97eb8d5?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=Yes%2C%20you%20can%20create%20a%20chart%20with%20%60query_context%60%20in%20a%20%2A%2Asingle%20API%20call%2A%2A%20%E2%80%94%20no%20need%20to%20create%20first%20and%20update%20later.%0A%0AThe%20%5BChartPostSchema%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py%23L167-L226%29%20accepts%20%5B%60query_context%60%20as%20an%20optional%20field%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py%23L86-L90%29%20during%20chart%20creation%3A%0A%0A%60%60%60python%0APOST%20/api/v1/chart/%0A%7B%0A%20%20%20%20%22slice_name%22%3A%20%22My%20Chart%22%2C%0A%20%20%20%2 0%22datasource_id%22%3A%201%2C%0A%20%20%20%20%22datasource_type%22%3A%20%22table%22%2C%0A%20%20%20%20%22viz_type%22%3A%20%22table%22%2C%0A%20%20%20%20%22params%22%3A%20%22%7B...%7D%22%2C%20%20%23%20your%20form_data%20as%20JSON%20string%0A%20%20%20%20%22query_context%22%3A%20%22%7B...%7D%22%20%20%23%20your%20query_context%20as%20JSON%20string%0A%7D%0A%60%60%60%0A%0ASo%20your%20workflow%20can%20be%3A%0A1.%20Build%20your%20%60params%60%20%28form_data%29%20and%20%60query_context%60%20JSON%20strings%0A2.%20Create%20the%20chart%20with%20both%20in%20one%20POST%20request%0A3.%20Then%20%60warm_up_cache%60%20will%20work%20immediately%20since%20%60query_context%60%20is%20already%20stored) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter .com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/38718) GitHub link: https://github.com/apache/superset/discussions/38718#discussioncomment-16207244 ---- 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]
