Search code examples
phpiframeembedmetabase

Metabase embed question fails with Assert failed: (integer? card-id)


Trying to embed a question using iframe in my application. I've followed the instructions here: https://www.metabase.com/docs/latest/administration-guide/13-embedding.html

Code (PHP):

 $payload = (object) [
            'resource' => ['question' => 20],
            'params'=> [

            ]
        ];

        $token = JWT::encode($payload, env('METABASE_SECRET_KEY'));

        $iframeUrl = env('METABASE_SITE_URL') . "/embed/question/{$token}/#bordered=true&titled=true";

HTML:

 <iframe
    src="{{$iframeUrl}}"
    frameborder="0"
    width="800"
    height="600"
    allowtransparency
></iframe>

Error:

error message

It seems like it's trying to authenticate the user and fails:

failed requests


Solution

  • As the error suggests question id should be an integer. Solved by casting to int