Question

Running Filtered Dashboards using the Ruby API

  • 24 June 2016
  • 1 reply
  • 156 views

I’m trying to use https://github.com/looker/looker-sdk-ruby to run a filtered dashboard using the API.


I can easily get the results without specifying any filters using:


sdk.update_dashboard 64, {load_configuration: “prefetch_cache_run”}

sdk.create_dashboard_prefetch 64, ttl: 30

sdk.dashboard_prefetch 64, ttl: 30 # this works fine - I can see my data in the result


But as soon as I try to specify dashboard_filters as specified in the docs, I get:


LookerSDK::InternalServerError: An error has occurred.


With this code:


filters = [

{

name: “Email”,

value: "test@example.com"

}

]


sdk.create_dashboard_prefetch 64, ttl: 30, dashboard_filters: filters

sdk.dashboard_prefetch 64, ttl: 30, dashboard_filters: filters # this raises the error posted above


Any advice or even just some working example code would be appreciated


1 reply

HI Jasdeep!


I think this may just be a simple typo. Checking the API documents, it looks like there isn’t a filters ‘value’ parameter. Try using ‘default_value’ for the email address and it ought to work!


You can access the API docs on your instance either by going directly to the URL below, or, if you’re an Admin, by navigating to Admin>API>View documents:


https://<your_awesome_company>:19999/api-docs/index.html#!/Dashboard/create_dashboard


Here’s the relevant documentation:


"filters": [

{

"id": 0,

"name": "string",

"title": "string",

"type": "string",

"default_value": "string",

"model": "string",

"explore": "string",

"dimension": "string",

"field": "string",

"listens_to_filters": [

"string"

]

}'


Cheers!

Dave

Reply