Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To modify the description box of Metabase cards using Metabase API through Google Sheets, follow these steps:

  1. Go to the Google Sheets document where you want to modify the Metabase card description box.

  2. Open the script editor by clicking on Tools > Script editor.

  3. In the script editor, copy and paste the following code:

function updateDescription(cardId, newDescription) {
  var apiUrl = 'https://<your-metabase-url>/api/card/' + cardId;
  var payload = {
    "description": newDescription,
  };
  var options = {
    "method": "PUT",
    "headers": {
      "Content-Type": "application/json",
      "X-Metabase-Session": "<your-metabase-session>"
    },
    "payload": JSON.stringify(payload)
  };
  var response = UrlFetchApp.fetch(apiUrl, options);
  Logger.log(response.getContentText());
}
  1. Replace <your-metabase-url> with your actual Metabase URL.

  2. Replace <your-metabase-session> with your Metabase session token. You can get it by logging in to Metabase, going to the Settings > Admin > Session, and copying the API Session Token.

  3. Save the script and close the script editor.

  4. In your Google Sheets document, add a new column for the description.

  5. Fill in the new column with the updated descriptions for each card.

  6. In any cell outside of the description column, enter the following formula: =updateDescription(cardId, description) and replace cardId with the ID of the Metabase card and description with the cell reference of the new description.

  7. Press enter and wait for the script to run. You should see the response in the script editor console.

  8. Check your Metabase cards to confirm that the description has been updated.