Ask Your Question
1

How can the description box of Metabase cards be modified using Metabase API through Google Sheets?

asked 2023-06-14 06:28:46 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-14 06:57:01 +0000

pufferfish gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-14 06:28:46 +0000

Seen: 11 times

Last updated: Jun 14 '23