5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

metabaseのv0.52系からv0.53系のバージョンアップで、APIの変数の指定方法が変わった

Posted at

対象のAPI エンドポイント

/api/card/${card-id}/query/${export-format}

結論

  1. 変数の指定の方法が、クエリーパラメーターから、bodyに変更。
  2. パラメータが2つ追加(format_rows, pivot_results)

具体的に

v0.52系

POST https://$domain/api/card/$card-id/query/json?parameters=[{ "target": ["variable", ["template-tag", "${変数名}"]],"type": "category", "value": "${変数の値}"}]
Content-Type: application/json
x-api-key: $x-api-key

v0.53系

POST https://$domain/api/card/$card-id/query/json
Content-Type: application/json
x-api-key: $x-api-key
{
  "format_rows": false,
  "pivot_results": false,
  "parameters": [
    {
      "type": "category",
      "target": ["variable", ["template-tag", "${変数名}"]],
      "value": "${変数の値}"
    }
  ]
}

気をつけること

  1. クエリの変数にデフォルト値が設定されてると、今までのクエリパラメータ方式の変数が渡らずデフォルト値でAPIが実行され、成功(200)する
  2. クエリに変数のデフォルト値が設定さず、必須にしてると、失敗(400)する
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?