jtornblad opened a new issue #15457:
URL: https://github.com/apache/superset/issues/15457


   When creating a dashboard with the API (POST `/dashboard/), the response 
indicates success but the resulting dashboard is not functional.  The charts do 
not appear to be operative.
   
   ### Expected results
   
   Creation of a dashboard with the API should result in a properly functioning 
dashboard / charts, just the same as if the dashboard were created manually 
with the UI.
   
   ### Actual results
   
   Dashboard is successfully created, however the charts are nonoperational.
   
   #### Screenshots
   
   here
   
   #### How to reproduce the bug
   
   Prerequisites:
   + CSRF is disabled (add `WTF_CSRF_ENABLED = False` to superset/config.py)
   + Install `curl` for testing the API and `jq` for parsing JSON
   + `SUPERSET_HOST=localhost:8088`
   + `SUPERSET_USER=admin; SUPERSET_PASSWORD=admin`
   
   1. Obtain a TOKEN
   `TOKEN=$(curl -s http://$SUPERSET_HOST/api/v1/security/login -H 'accept: 
application/json' -H 'Content-Type: application/json' -d '{ "password": 
"'$SUPERSET_PASSWORD'", "provider": "db", "refresh": true, "username": 
"'$SUPERSET_USER'" }' | jq -r .access_token)`
   
   2. Look up example chart "Daily Totals"
   `CHART_ID=$(curl -s -H 'Authorization: Bearer '$TOKEN'' -H 'accept: 
application/json' 
'http://'$SUPERSET_HOST'/api/v1/chart/?q=%7B%0A%20%20%22filters%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22col%22%3A%20%22slice_name%22%2C%0A%20%20%20%20%20%20%22opr%22%3A%20%22eq%22%2C%0A%20%20%20%20%20%20%22value%22%3A%20%22Daily%20Totals%22%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D'
 | jq '.result[0].id')`
   
   3. Create a dashboard with the chart
   `curl -s 'http://'$SUPERSET_HOST'/api/v1/dashboard/' \
     -H 'Authorization: Bearer '$TOKEN'' \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '{
       "dashboard_title": "TestDashboard",
       "json_metadata": "{\"timed_refresh_immune_slices\": [], 
\"expanded_slices\": {}, \"refresh_frequency\": 0, \"default_filters\": \"{}\", 
\"color_scheme\": null}",
       "position_json": 
"{\"CHART-w2_C20sz-l\":{\"children\":[],\"id\":\"CHART-w2_C20sz-l\",\"meta\":{\"chartId\":67,\"height\":50,\"sliceName\":\"Daily
 
Totals\",\"uuid\":\"5ffc22e4-244e-491d-965b-b7d178845df2\",\"width\":4},\"parents\":[\"ROOT_ID\",\"GRID_ID\",\"ROW-qDUg8z__N5\"],\"type\":\"CHART\"},\"DASHBOARD_VERSION_KEY\":\"v2\",\"GRID_ID\":{\"children\":[\"ROW-qDUg8z__N5\"],\"id\":\"GRID_ID\",\"parents\":[\"ROOT_ID\"],\"type\":\"GRID\"},\"HEADER_ID\":{\"id\":\"HEADER_ID\",\"meta\":{\"text\":\"[
 untitled dashboard 
]\"},\"type\":\"HEADER\"},\"ROOT_ID\":{\"children\":[\"GRID_ID\"],\"id\":\"ROOT_ID\",\"type\":\"ROOT\"},\"ROW-qDUg8z__N5\":{\"children\":[\"CHART-w2_C20sz-l\"],\"id\":\"ROW-qDUg8z__N5\",\"meta\":{\"background\":\"BACKGROUND_TRANSPARENT\"},\"parents\":[\"ROOT_ID\",\"GRID_ID\"],\"type\":\"ROW\"}}",
       "published": false
     }'`
   
   An HTTP 200 Success response is returned with this body:
   
   `{
     "id": 13, 
     "result": {
       "dashboard_title": "TestDashboard", 
       "json_metadata": "{\"timed_refresh_immune_slices\": [], 
\"expanded_slices\": {}, \"refresh_frequency\": 0, \"default_filters\": \"{}\", 
\"color_scheme\": null}", 
       "position_json": 
"{\"CHART-w2_C20sz-l\":{\"children\":[],\"id\":\"CHART-w2_C20sz-l\",\"meta\":{\"chartId\":67,\"height\":50,\"sliceName\":\"Daily
 
Totals\",\"uuid\":\"5ffc22e4-244e-491d-965b-b7d178845df2\",\"width\":4},\"parents\":[\"ROOT_ID\",\"GRID_ID\",\"ROW-qDUg8z__N5\"],\"type\":\"CHART\"},\"DASHBOARD_VERSION_KEY\":\"v2\",\"GRID_ID\":{\"children\":[\"ROW-qDUg8z__N5\"],\"id\":\"GRID_ID\",\"parents\":[\"ROOT_ID\"],\"type\":\"GRID\"},\"HEADER_ID\":{\"id\":\"HEADER_ID\",\"meta\":{\"text\":\"[
 untitled dashboard 
]\"},\"type\":\"HEADER\"},\"ROOT_ID\":{\"children\":[\"GRID_ID\"],\"id\":\"ROOT_ID\",\"type\":\"ROOT\"},\"ROW-qDUg8z__N5\":{\"children\":[\"CHART-w2_C20sz-l\"],\"id\":\"ROW-qDUg8z__N5\",\"meta\":{\"background\":\"BACKGROUND_TRANSPARENT\"},\"parents\":[\"ROOT_ID\",\"GRID_ID\"],\"type\":\"ROW\"}}",
 
       "published": false
     }
   }`
   
   4. Using the Superset UI, examine the "TestDashboard" just created, the 
chart on the dashboard displays the message (see screenshot)
   
   "There is no chart definition associated with this component, could it have 
been deleted?
   Delete this container and save to remove this message."
   
   ### Environment
   
   - superset version: `1.2.0rc2`
   
   ### Checklist
   
   - [X] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [X] I have reproduced the issue with at least the latest released version 
of superset.
   - [X] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   
   ### Additional context
   
   Related to issue with obtaining chart UUIDs for creation of dashboard 
through API:
   #15456 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to