What value should "raw-params" take in the Table API's "replace-csv" endpoint

Hi legends,

I'm testing the Metabase API and I'm eager to use the POST /api/table/:id/replace-csv endpoint. I would love some help understanding what is meant by raw-params in the API docs for that endpoint

I'll add my questions below and please also feel free to point me to any existing resources or links on this topic - I couldn't find any in my own searches in the Discourse community or in the GitHub issue tracker. The most relevant link I could find is the Pull Request that originally created the endpoint: Basic version of CSV replacement, with only basic testing by crisptrutski · Pull Request #40363 · metabase/metabase · GitHub

Questions:

  1. Are there any code samples/examples available for using this endpoint?
  2. Based on the PR linked above, it appears the raw-params relates to a request body that looks something like the below, but I can't get it to work. What's the correct structure for the raw-params argument?
    {
        "raw-params": {
            "file": "...contents of csv file...",
        }
    }
    
  3. Are the file contents supposed to be a literal CSV structure containing the full data as a string (i.e. no base64 encoding or anything), something like the below?
    {
        "file": "id,first_name,email\n1,Jo,jo@example.com\n2,Mary,mary@example.com",
    }
    

Thanks in advance for any help you can offer and please let me know if there is any extra clarity I can add!

hey I haven't used this endpoint (yet), but have you seen how the browser does the calls to the backend to try to understand what's going on?

1 Like

@coreym

In case this helps anyone else.
It's a multi-part/form POST call so you can try something like the following:

curl -X POST http://yourmetabaseapp.com/api/card/from-csv
-H "X-API-KEY: YOUR_API_KEY"
-F "file=@/path/to/your/file.csv"
-F "collection_id=4" ← whatever collection ID you want to use

If that works, you should be able to adapt it to whatever ecosystem/language.