Hello,
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;
}
curl_close($ch);
var_dump($return_data);
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'))));