Thanks for flagging. There should be enhanced API documentation specific to Lakeview in the next week or two (PR is in review). Keep an eye out for a page called "Use the Lakeview API and Workspace API to create and manage Lakeview dashboards."
Currently, there is API support for Lakeview dashboard:
- Export/Import (via workspace APIs)
- List (via workspace APIs)
- Get Status (via workspace APIs)
- Publish
Additional areas are under development.
For a bit more information on Lakeview dashboard export/import via API specifically....
Exporting a dashboard
If we want to export the contents of mydashboard.lvdash.json, we can use the Workspace Export API to do so.
GET /api/2.0/workspace/export
Query parameters:
{
"path": "/Users/my@user.com/examples/mydashboard.lvdash.json",
"direct_download": true
}
Response:
{
"pages": [
{
"name": "7db2d3cf",
"displayName": "New Page"
}
]
}
This response shows the contents of a minimal dashboard definition which is blank.
Note that the file name without extension is what appears as the name of the dashboard in the Workspace (mydashboard.lvdash.json). If the direct_download property is left out of the request or is set to false, the response will include the base64 encoded version of the json string. We will use this later for the import request.
GET /api/2.0/workspace/export
Query parameters:
{
"path": "/Users/my@user.com/examples/mydashboard.lvdash.json",
"direct_download": false
}
Response:
{
"content": "eyJwYWdlcyI6W3sibmFtZSI6IjdkYjJkM2NmIiwiZGlzcGxheU5hbWUiOiJOZXcgUGFnZSJ9XX0=",
"file_type": "lvdash.json"
}
Importing a dashboard
If we want to import another dashboard into the workspace using the same contents as mydashboard.lvdash.json, we can do so by using the Workspace Import API. For the import to be properly recognized as a Lakeview dashboard, a few important parameters must be set:
- "format": "AUTO" - this setting will allow the system to automatically detect the asset type.
- "path": needs the file path to end in ".lvdash.json". This in conjunction with the format will mean the content will attempt to import as a Lakeview dashboard.
If these settings are not configured properly, the import might succeed but the dashboard would be treated like a normal file.
POST /api/2.0/workspace/import
Request body parameters:
{
"path": "/Users/my@user.com/examples/myseconddashboard.lvdash.json",
"content": "eyJwYWdlcyI6W3sibmFtZSI6IjdkYjJkM2NmIiwiZGlzcGxheU5hbWUiOiJOZXcgUGFnZSJ9XX0=",
"format": "AUTO"
}
Response:
{}
If we were to immediately issue the same API request, we would get an error:
{
"error_code": "RESOURCE_ALREADY_EXISTS",
"message": "Path (/Users/my@user.com/examples/myseconddashboard.lvdash.json) already exists."
}
In order to overwrite the contents of an existing dashboard in place, the "overwrite" property can be set:
POST /api/2.0/workspace/import
Request body parameters:
{
"path": "/Users/my@user.com/examples/myseconddashboard.lvdash.json",
"content": "eyJwYWdlcyI6W3sibmFtZSI6IjdkYjJkM2NmIiwiZGlzcGxheU5hbWUiOiJOZXcgUGFnZSJ9XX0=",
"format": "AUTO",
"overwrite": true
}
Response:
{}