Updating a database’s filename using API

Hello. I’m trying to update a database’s filename details within metabase using the API.

Using version 0.45.1.

Working from: How to configure metabase dasbhoard without docker | CrowdSec

The current value is:


I can successfully get my authentication token, then I do the following:

curl -X PUT \
    -H "Content-Type: application/json" \
    -H "X-Metabase-Session: $TOKEN" \
    http://localhost:3000/api/database/2 \
    -d '{
        "id": "2",
        "engine": "sqlite",
        "name": "Crowdsec",
        "details": {
            "dbname": "/opt/crowdsec/metabase.db"

And get the following error:
{"message":"/metabase-data/crowdsec.db (No such file or directory)"}

(That particular directory does not exist on the system, trying to modify it to point to a new directory programmatically).

Unfortunately I'm a complete amateur at this, and not quite sure how to proceed (if at all possible).

Further info:

curl -X GET \
  -H "Content-Type: application/json" \
  -H "X-Metabase-Session: $TOKEN" \
{"description":null,"features":["basic-aggregations","temporal-extract","date-arithmetics","expression-aggregations","foreign-keys","left-join","native-parameters","nested-queries","expressions","binning","inner-join"],"cache_field_values_schedule":"0 0 16 * * ? *","timezone":"Etc/GMT","auto_run_queries":true,"metadata_sync_schedule":"0 49 * * * ? *","name":"Crowdsec","settings":null,"caveats":null,"can-manage":true,"creator_id":null,"is_full_sync":true,"updated_at":"2021-05-05T11:07:29.173","cache_ttl":null,"details":{"db":"/metabase-data/crowdsec.db"},"is_sample":false,"id":2,"is_on_demand":false,"options":null,"schedules":{"cache_field_values":{"schedule_minute":0,"schedule_day":null,"schedule_frame":null,"schedule_hour":16,"schedule_type":"daily"},"metadata_sync":{"schedule_minute":49,"schedule_day":null,"schedule_frame":null,"schedule_hour":null,"schedule_type":"hourly"}},"engine":"sqlite","initial_sync_status":"complete","refingerprint":null,"created_at":"2020-11-04T14:39:49.523","points_of_interest":null}


Hi @modem7
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.
Then you can copy the request as cURL and look at the difference between that and your example.
It's db, not dbname.

1 Like


Thank you so much for that.

I honestly wouldn't have thought to try that.

Found the answer and all resolved this end, cheers!