Can't pass parameters to the API

Hi,
I’m trying to get the results of a query (card?) through the API but I can’t work out how to pass parameters to my query. I’ve searched the forum, but can’t find anywhere that helps

It only takes one parameter, an order_number and I’m currently testing it in Postman.

I’ve tried:
setting it as a parameter with key=“order_number” and value=“2353044”
setting a parameter with key=“parameters” and value="[“order_number”:2353044]"
adding it to the URL directly
sending it as the Body as: {“order_number”:“2353044”}
sending it as the body as: [
{
“type”: “number”,
“target”: [
“variable”,
[
“order_number”
]
],
“value”: “2353044”
}
]

None of them work, I always just get back the error “error”: “‘order_number’ is a required param.”

I’m POSTing to https://our_metabase_url.com/api/card/1730/query

Can anyone help with how I should be sending the parameter in???

Hi @tayo.moore
The easiest way to learn the API is to just use the regular Metabase interface and open your browser developer console on the Network-tab, so you can follow requests and then click to see the exact parameters and responses.

Thanks, that was really helpful.

After looking through the Network tab, and playing around, I finally got it to work!!

For anyone needing this in the future, I have a question that has one parameter (a number) called order_number. I got it to work by having this as body of my request (with nothing in the parameters of the request)

{"parameters": [
	{
			"type": "category",
			"target": [
				"variable",
				[
					"template-tag",
					"order_number"
				]
			],
			"value": "2353044"
		}
	]}
1 Like