JSONDecodeError while running calling "download_dashboard_pdf.py" for exporting dashboard to pdf

Hi everyone, if anyone of you familiar with the looker API for noodlanding dashboard as pdf. I am facing some issue while passing filters in the code. Can you help me out.

I wants to add some filters on dashboard which are like below image.
 

0388081f-2d89-47b2-9872-afd4b2dfb98d.png

But while parsing those filter values as argument in the API giving error. Any one knows how to avoid/resolve this error. Or what is the correct format to pass the filter values.

I am parsing the argument as below which is mentioned in the github API doc. 

example :$ python download_dashboard_pdf.py "A Test Dashboard" '{"filter1": "value1, value2", "filter2": "value3"}'

actual code I am passing :  $ python download_dashboard_pdf.py "A Test Dashboard" ‘{“Account name “: “AFB”}’

a7de7729-73dc-4f94-8d5e-11f5b6e61dea.png
0 4 267
4 REPLIES 4

Hello @manishkamble19 ,

Yes, I could help you with that, add the following two lines to the code before defining filters:

filter_dict = {"Filter 1": "Value 1", "Filter 2": "Value 2"}
json_object = json.dumps(filter_dict)

Then define filters as:

filters = json.loads(json_object)

This should resolve your error, hope this helps!

Thanks @Ranjit_1312  this solution works fine but one thing I have notice this is hard coded within code. But my requirement is to set this as argument while passing values at start of running script. And I want to apply only single filter.

If I pass this as argument which you have suggested its showing me following error.

passing only dashboard name as a argument is works fine but once I added filter {Account Name : AFB} its giving me below error.
 

@Ranjit_1312 do you know how to resolve this issue.

3fe15d17-d1f6-425e-be7b-9b5b74f98e4b.png

naren2
Participant I

Were you finally able to download dashboard as pdf? I cud download but the corrupted one.. please help with the code if the download pdf worked for you. TIA

Hello @manishkamble19 ,

I was able to define and send the required arguments for filters as below:

    Date = "3 month"
Team_ID = str(filters_[1])

filt = {"Date": Date,"Team ID": Team_ID}

json_object = json.dumps(filt)
filters = json.loads(json_object) if json_object else None

Make sure that even though the filters in the Dashboard has “integer” setup, while passing those values through API they are required to be “string” characters. In the above referred code the “Team_ID” dashboard filter is setup as integer but still we are required pass them as ‘string’ character.

Hope that helps with your error.

Thanks,

Ranjit