Using API : POST /api/card/:card-id/query/:export-format


I have a question about the usage of the API (Card).

I don't know how to use the parameters.
I have two mandatory filters (start and end).
I'm using PHP :

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('end' => '2022-07-01', 'start' => '2022-01-01')));
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
	curl_setopt($ch, CURLOPT_URL, 'http://localhost:3000/api/card/1/query/csv');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$headers = array();
	$headers[] = 'Content-Type: application/json';
	$headers[] = 'X-Metabase-Session: ' . $token;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	$result = curl_exec($ch);			
	if (curl_errno($ch)) {
		$return_data = array("error" => curl_error($ch));
	} else {
		$return_data = $result;	

Result :

'{"database_id":3,"started_at":"2022-11-24T14:00:17.8586233+01:00","via":[{"status":"failed","class":"class clojure.lang.ExceptionInfo","error":"Error determining value for parameter "end": You'll need to pick a value for 'End' before this query can run.","stacktrace":["--> driver.common.parameters.values$fn__81571$value_for_tag__81576$fn__81577.invoke(values.clj:327)","driver.common.parameters.values$fn__81571$value_for_tag__81576.invoke(values.clj:320)","driver.common.parameters.values$fn__81595$query__G'... (length=84288)

Also tried :

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("parameters" => array('end' => '2022-07-01', 'start' => '2022-01-01'))));

Hi @Exe
Please read this: API POST /api/card/:card-id/query/:export-format with parameters

Thnaks for yhe answer @flamber but in the response and don't see any reference to id.
In my network tab, I can see the payload is like :


How can I determine the id and to what it is referencing to ?


I tried the following in my request :

		$ch, CURLOPT_POSTFIELDS, json_encode(
					"parameters" => array(
						"type" => "date/single", "value" => "2022-07-01", "target" => array(
							"variable", array(
					"parameters" => array(
						"type" => "date/single", "value" => "2022-01-01", "target" => array(
							"variable", array(

But I'm still getting the issue

@Exe That is coming from the question metadata /api/card/:id

Here's a tip - read through everything in the topic I linked to.

Then copy the cURL command via your browser developer Network-tab, and compare that to the cURL command that you are generating in code, and you'll easily spot the difference.