Is there an API call to select dark mode for a named space?

I'd like to set the dark mode theme on a non-default Kibana Space using a curl command.

Is this possible?

For the default space, I can use the command below, but I can't find anything for specific spaces.

curl -XPUT "#{kibana_url}/api/saved_objects/config/7.1.1" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d'                                                                                                                                                                                                                                                                                                                                                                                                                                    {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  "attributes": {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    "theme:darkMode": true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   }'

The saved object API is also available on each space:

PUT <kibana host>:<port>/s/<space_id>/api/saved_objects/<type>/<id>

Reference: https://www.elastic.co/guide/en/kibana/7.6/saved-objects-api-update.html

Thanks, I tried that but I'm not having much luck with it :slight_smile:

Here's my code, it sets dark mode for the default space, and then for the 'new' space:

    PUT <kibana host>:<port>/api/saved_objects/config/7.1.1 -d '
    {
      "attributes": {
        "theme:darkMode": true
      }
    }'

    PUT <kibana host>:<port>/s/new/api/saved_objects/config/7.1.1 -d'
    {
      "attributes": {
        "theme:darkMode": true
      }
    }'

The first part works as expected, but for the second call I get this result:
{"statusCode":404,"error":"Not Found","message":"Saved object [config/7.1.1] not found"}

I think if you have never changed the config in the separate space, the saved object won't exist (this is why updating it fails). Try creating a new config saved object instead.

That has worked! :slight_smile:

Thanks very much for your help with this :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.