I am doing a post query to Metabase for a question which takes parameters. However, the query does not complete due to a missing-required-parameter
error. Instead, the returned information from Metabase (some data omitted) is
{"database_id":X,"started_at":"2021-07-02T15:32:01.569753Z","error_type":"missing-required-parameter","json_query":{"constraints":null,"type":"native","middleware":{"skip-results-metadata?":true,"format-rows?":false,"js-int-to-string?":true},"native":{"template-tags":{"param1":{"id":"XXX","name":"param1","display-name":"param1","type":"number","required":false}},"query":"XXXX","database":X,"parameters":null,"async?":true,"cache-ttl":null},"status":"failed",................"context":"json-download","error":"Cannot run the query: missing required parameters: #{\"param1\"}","row_count":0,"running_time":0,"ex-data":{"type":"missing-required-parameter","missing":["param1"]},"data":{"rows":[],"cols":[]}}
I have reviewed Metabase forum posts 8113 and 11331 (apologies I cannot post links due to "new member limitations") discussing this issue, in addition to the docs to determine what causes the failure. It appears my syntax is correct, but perhaps I am missing something.
To run the query, I do the following after obtaining ${token} (in a bash script):
curl -X POST
-H "Content-Type: application/json"
-H "X-Metabase-Session: ${token}"
-d '{"parameters":[{"type":"category","target":["variable",["template-tag","param1"]],"value":"2064"}]}'
https://metabase.XXXXX.com/api/card/218/query/json
The format of the parameters data is identical to that in the "json_query" observed when running the Metabase query in the online UI in my browser's developer mode. At this point, I do not know why Metabase sees parameters as null
. Any help is kindly appreciated, thank you!