Embed a question with optional parameters

I would like to embed a query, with optional parameters.

the query in the question:

SELECT ID, FIELD1, FIELD2
FROM TABLE1
WHERE 1=1
[[AND FIELD1 = {{param1}}]]
[[AND FIELD2 = {{param2}}]]

the payload variable:

{ "resource": { "question": 22 }, "params": {"param1":[204], "param2":[]}, "Exp":1624102224.304698}

the token:

"https://jwt.io/#debugger-io?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6eyJxdWVzdGlvbiI6MjJ9LCJwYXJhbXMiOnsicGFyYW0xIjpbIjIwNCJdLCJwYXJhbTIiOltdfSwiRXhwIjoxNjI0MTAyMjI0LjMwNDY5Nzk5MDQsImV4cCI6MTYyNDEwMTYyNSwiaWF0IjoxNjI0MTAxNjI0fQ.RLd0Ja3X1WynjwEbcxtOL7e3YTln8a2mNqCbGQ9AbuA"

when I run the question in my webapp, I get from Metabase the response "unknown parameter :param2".

I've read the documentation and many discussions, but I can't solve it.

thanks for the help.

{
"browser-info": {
"language": "en-US",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.11+9-Ubuntu-0ubuntu2.18.04",
"java.vendor": "Ubuntu",
"java.vendor.url": "https://ubuntu.com/",
"java.version": "11.0.11",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.11+9-Ubuntu-0ubuntu2.18.04",
"os.name": "Linux",
"os.version": "4.15.0-144-generic",
"user.language": "en",
"user.timezone": "Europe/Rome"
},
"metabase-info": {
"databases": [
"sqlserver",
"h2"
],
"hosting-env": "unknown",
"application-database": "postgres",
"application-database-details": {
"database": {
"name": "PostgreSQL",
"version": "10.17 (Ubuntu 10.17-0ubuntu0.18.04.1)"
},
"jdbc-driver": {
"name": "PostgreSQL JDBC Driver",
"version": "42.2.18"
}
},
"run-mode": "prod",
"version": {
"date": "2021-05-17",
"tag": "v0.39.2",
"branch": "release-x.39.x",
"hash": "b0d9436"
},
"settings": {
"report-timezone": null
}
}
}

Hi @wjz
Are you sure that param2 variable has been set to "Locked", when you open the embed dialog?
If you want to set optional parameters (meaning "Enabled"), then you don't define those in your embed code, but just in the URL.

1 Like

Sorry, my stupid mistake.
I'm recently using this wonderful product.
can I mark my question as solved?