在生成 QuickSight embedded 报告的 URL 时以代码的方式配置参数值

0

【以下的问题经过翻译处理】 我正在研究如何生成 QuickSight embedded 报告的 url 。我正在尝试使用以下 JAVA 代码以程式的方式设置参数的默认值。但它不起作用。

          GetDashboardEmbedUrlRequest req =  new GetDashboardEmbedUrlRequest()
            .withAwsAccountId(awsAccountId)
            .withDashboardId(reportInput.getDashboadId())
            .withUserArn(userArn)
            .withIdentityType(EmbeddingIdentityType.QUICKSIGHT)
            .withSessionLifetimeInMinutes(sessionTimeout);
          req.putCustomQueryParameter("CampaignName", "ABC");
          req.putCustomQueryParameter("reportDev", "Program");
        // get the dashboard URL
        String embedUrl = quickSightClient.getDashboardEmbedUrl(req).getEmbedUrl();

        LOGGER.info("URL:{}",embedUrl);

在上面的代码中,“CampaingName”是附加到下拉列表里的多值参数。在构建报告时,它的默认值设置为“[All]”。参数“reportDev”是一个单值参数并且没有默认值,也没有控件或任何附加物。我在测试中引入了虚拟参数。

运行代码后,当我复制logger在控制台中输出的 url 并在浏览器中运行时,报告会正确打开,但“CampaignName”和“reportDev”都被设置为了“ALL”。

示例生成的 url 如下

https://xx-xxxx-x.quicksight.aws.amazon.com/embed/xxxxxxxxxxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxxxxxxxxx?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&identityprovider=quicksight&isauthcode=true

但如果我得了dashboard的 url 并将 url 中的参数传递给它,它就可以正常工作。 “CampaignName”设置为“ABC”,“reportDev”设置为“Program”。也根据报告中的数据进行了过滤。Url正常工作,如下所示。

https://xx-xxxx-1.quicksight.aws.amazon.com/embed/xxxxxxxxxxxx/dashboards/xxxxxxxxxxxxxxx#p.reportEnv=Program&p.CampaignName=ABC

谁能告诉我我的代码中缺少什么?我也尝试过以下变量,但没有效果。

          req.putCustomQueryParameter("p.CampaignName", "ABC");
          req.putCustomQueryParameter("p.reportDev", "Program");


profile picture
EXPERT
asked 6 months ago17 views
1 Answer
0

【以下的回答经过翻译处理】 这些是在对 AWS 服务的 HTTP 请求中使用的自定义查询参数。请参阅 putCustomQueryParameter

您是否使用 Javascript SDK 进行嵌入?如果是这样,您可以设置/获取 *Dashboard *parameters

profile picture
EXPERT
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions