We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I'm trying to download a report in csv using API. I found the endoit (I hope it's the right one):
POST /api/dataset/:export-format Execute a query and download the result data as a file in the specified format. PARAMS: export-format value must be one of: api, csv, json, xlsx. query value must be a valid JSON string. visualization_settings value must be a valid JSON string.
POST /api/dataset/:export-format Execute a query and download the result data as a file in the specified format.
PARAMS: export-format value must be one of: api, csv, json, xlsx.
query value must be a valid JSON string.
visualization_settings value must be a valid JSON string.
I wrote it in PHP :
public function DownloadCSV($token, $query, $exportFormat) { if($exportFormat == "api" or $exportFormat == "csv" or $exportFormat == "json" or $exportFormat == "xlsx"){ $ch = curl_init(); //https://github.com/metabase/metabase/blob/master/docs/api/dataset.md var_dump($this->MetabaseURL.'/api/dataset/'.$exportFormat); curl_setopt($ch, CURLOPT_URL, $this->MetabaseURL.'/api/dataset/'.$exportFormat); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, "query=$query"); $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)) { echo 'Error:' . curl_error($ch); } curl_close($ch); file_put_contents("text.txt", $result); return $result; } }
Output :
string 'http://localhost:3000/api/dataset/csv' (length=37) string 'Malformed JSON in request body.' (length=31)
The query contain a SQL request.
How do I format query and visualization_settings ?
query
visualization_settings
And i'll like to update the data before exporting, how can I update the data ? Thanks
The text was updated successfully, but these errors were encountered:
Please use the forum for questions and troubleshooting: https://discourse.metabase.com/
Sorry, something went wrong.
No branches or pull requests
Hello,
I'm trying to download a report in csv using API.
I found the endoit (I hope it's the right one):
I wrote it in PHP :
Output :
The query contain a SQL request.
How do I format
query
andvisualization_settings
?And i'll like to update the data before exporting, how can I update the data ?
Thanks
The text was updated successfully, but these errors were encountered: