Can I update my dashboard with a new custom slug using update_dashboard?

Knowledge Drop

Last tested: Feb 10, 2021
 

Yes, we can update the dashboard with a custom slug but please note dashboard slugs are required to be 22 characters long.

If we try to use the update_dashboard endpoint with a slug that's less than 22 characters, we'll see the following error message.

 

# Node SDK

const dashboard = await lookerSDK.ok(lookerSDK.dashboard("123"))

const test = await lookerSDK.update_dashboard("123", {slug: "slugtest"});

# Results in this error

error: {

message: 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined',

type: 'sdk_error'

},

This content is subject to limited support.                

Comments
marc
Participant I

Is there an explanation somewhere of why the slugs need to be exactly 22 characters? This seems arbitrary yet specific

xavivuk
New Member

Just in case someone else stumbles across this, i had to import dashboards into a shared folder with an explicit slug:

# Python SDK - import dashboard and save it as a variable

dashboard = sdk.import_lookml_dashboard(lookml_dashboard_id=”dashboard_id_here”, space_id=”folder_id_here”)

#change the vaiable dasboard - slug property

dashboard.slug = “new_slug_here”

#update the imported dashboard with the new slug

sdk.update_dashboard(dashboard_id=dashboard.id, body=dashboard)

Ryan_PS
Participant III

Is there an explanation somewhere of why the slugs need to be exactly 22 characters? This seems arbitrary yet specific

The reason is likely because slugs are, by default, a randomized 22-character alphanumeric ID. Changing the slugs to be a custom slug is doing so within the confines of that existing logic.

----------------------------------------------------------------------------------

My team uses slugs specifically so that a dashboard that exists across 2 different Looker instances can be referenced by the same slug (we can’t use the dashboard IDs because the IDs are different per each instance).

We use a cloud function which uses the Looker API to update a dashboard’s slug. Then, when we perform a production deployment*, our looker dashboards from our staging instance are copied over to our production instance (which overwrite existing dashboards that have the same dashboard name within the same folder under “Shared”). This allows our production dashboards to have the same slug. An alternate route is just to update the production dashboard slug via API as well.

*Our production deployment uses GitHub Actions and gazer, which is covered here: 

https://community.looker.com/open-source-projects-78/gazer-a-command-line-tool-for-looker-content-ma...

Version history
Last update:
‎07-07-2021 01:12 PM
Updated by: