Parameters are not taken into account using Metabase API

Hello,
I am using the Metabase API via python and I am trying to pass parameters to a question using tPOST /api/card/:card-id/query/:export-format. I am passing the parameters like this:

import requests

url = f'https://metabase-adress/api/card/2319/query/json'

headers = {'Content-Type': 'application/json', 'X-Metabase-Session': 'session-id'}

data = {"parameters": [{"type": "id", "target": ["dimension", ["template-tag", "org_id"]], "value": "12345"}]}

response = requests.post(url, headers=headers, data=data)

The parameters are not taken into account in the query. I used the data from the network tab in the developer tools to get the right serialized JSON for the parameters so that part should be correct. It does work using the curl command.

curl -X POST \
  -H "Content-Type: application/json" \
  -H "X-Metabase-Session: session_id" \
  -d '{"parameters": [{"type": "id","value": ["12345"],"target": ["dimension",["template-tag","master_org_id"]]}]}' \
  https://metabase-adress/api/card/2319/query/json

Any ideas?

Thanks
Marion

Hi @marionchan
Have a look here: API POST /api/card/:card-id/query/:export-format with parameters

Hello @flamber
I have tried to use
data = "parameters=%5B%7B%22type%22%3A%22date%2Fall-options%22%2C%22value%22%3A%22past6months%22%2C%22target%22%3A%5B%22dimension%22%2C%5B%22template-tag%22%2C%22usage_date_range%22%5D%5D%7D%2C%7B%22type%22%3A%22id%22%2C%22value%22%3A%5B%2289351%22%5D%2C%22target%22%3A%5B%22dimension%22%2C%5B%22template-tag%22%2C%22org_id%22%5D%5D%7D%2C%7B%22type%22%3A%22string%2F%3D%22%2C%22value%22%3A%5B%22top99p%22%5D%2C%22target%22%3A%5B%22dimension%22%2C%5B%22template-tag%22%2C%22aggregation_function%22%5D%5D%7D%5D"

response = requests.post(url, headers=headers, data=json.dumps(data))

and
response = requests.post(url, headers=headers, data=data)
and
response = requests.post(url, headers=headers, json=json.dumps(data))

And it still doesn't work, any idea?

Thanks
Marion

@marionchan Use your browser. Then copy the cURL or Fetch request and compare it to what you're doing.