CURL - PHP code for Metabase question

Hello,

I am new to this forum, seeking help to understand the work around for my query. One of our Vendor has moved from php database to metabasen and all the sales are now displayed on screen via metabase query with public question created by them. Its a link basically which throws the output on screen with .csv, .json and .xlsx optoin to download. We here have a php designed with throws the output with additional ino like area, sales agent name etc.

Problem is here -

We have an internal portal which has lot of other options. One option is daily sales report in which earlier data was fetched using crul code and without any manual intervention, our database was fetching new sales entries in database and our portal get updated accordingly. Now when our vendor has shifted to metabase, this curl code is failing to get the records from there.

Can anyone please help me with the curl code as Vendor wont share password or field names of his metabase data. Nor he is willing to share any API or create a link and share it with us to implement in our php program...

Basically, I want the manual donwload portion to get replaced with curl code in php coding so that our portal can get updated automataclly.

Hi @galajits
Everything you can do in the Metabase interface can also be done with cURL through the API.
https://www.metabase.com/learn/developing-applications/advanced-metabase/metabase-api.html
The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.
And most browsers allows you to right-click the request and "copy as cURL"

I won't be able to help further, since you're not providing enough information, but I can only give one recommendation: Leave the vendor.

I requested Vendor to get me the API to integrate in my PHP portal, but they are not giving that. Cannot leave Vendor too as its a part of our client contract. That is where the hook is. Cant we do anything with question http://analytics.xxx.org:3000/public/question/340djslxd-xx33ccklfd33-4395dkdmllskvms023 in curl to save the .csv file automatically on server

@galajits Every public question can be downloaded as CSV/XLSX/JSON directly by adding extension to the end like this:
/public/question/340djslxd-xx33ccklfd33-4395dkdmllskvms023.csv

Hi

I tried in multiple ways to download, but with no luck.

Can anyone help me with the php code which will download the csv file from public/question link

@galajits

  1. Post "Diagnostic Info" from Admin > Troubleshooting.
  2. Post your PHP code. And post any errors that you encounter, since it's impossible to know how/what you have been trying.
  3. Perhaps your code is not handling the redirect, then try downloading directly from the API:
    /api/public/card/340djslxd-xx33ccklfd33-4395dkdmllskvms023/query/csv

Metabase access is with our Vendor. I wont be getting the access to their admin panel. Thats the main issue, else, I would have created a API and used it in PHP cURL. All I have is the public/question with token id.

Please help! :cry:

@galajits I don't understand what you need help with. You can export CSV files via the URL:
http://analytics.xxx.org:3000/api/public/card/340djslxd-xx33ccklfd33-4395dkdmllskvms023/query/csv

Otherwise contact the vendor - or leave them - I don't see how anyone here is going to be able to help you with the problem.

What will be the curl code to download output of question directly in. Csv without clicking on download as csv

But this does not work in my case.

@galajits Use your browser developer Network-tab to view requests and most browsers allows you to right-click that request and copy as cURL.

I cannot help you - you need to contact the vendor.

I got user id and password from vendor. One door is open. But i am looking for curl code to download the csv output directly without clicking on it

@galajits Yes, do it manually one time, look at your request and then write a script which does it automatically.

ok, so here's what's happening. when i open this question (http://analytics.abc.org:3000/public/question/4cfaq945-4d53-4559-844e-5fw3rwe4d9e3cd.csv)in brower, .csv file downloads with the correct output. but when I use the curl to download the csv file, it gives me blank output.

@galajits Again, like I already posted back in May 2021 (CURL - PHP code for Metabase question), there's a redirect, so follow which request is actually making the download.