为可编辑的 Power BI Embedded 仪表板生成嵌入令牌时出错

Error generating embed token for editable Power BI Embedded dashboard

我正在使用 Powershell 脚本为 Power BI 仪表板生成嵌入令牌:

Login-PowerBI

$url = "https://api.powerbi.com/v1.0/myorg/groups/395ce617-f2b9-xyz/dashboards/084c9cc4-xyz/GenerateToken"

$body = "{ 'accessLevel': 'View' }"

$response = Invoke-PowerBIRestMethod -Url $url -Body $body -Method Post -ErrorAction "Stop"
$response

$json = $response | ConvertFrom-Json
$json.token

这行得通,但是我希望通过像这样更改 accessLebel 来使仪表板可编辑:

$body = "{ 'accessLevel': 'Edit' }"

没有生成令牌,而是抛出一个错误指示 Bad Request,但没有其他详细信息。我如何确定应如何创建请求?仪表板是否像报告一样可编辑? (我可以毫无问题地为报告生成编辑令牌)我找不到代码示例,我注意到在线示例不允许您像使用报告那样编辑仪表板:https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html

您收到错误请求错误,因为访问级别:仪表板不支持编辑。 为群组中的仪表板生成 EmbedToken 支持的 accessLevel 仅为 View。

创建和编辑 accessLevel 仅适用于报告。

参考这个link:https://docs.microsoft.com/en-us/rest/api/power-bi/embedtoken/dashboards_generatetokeningroup#tokenaccesslevel

您可以使用那里的试用功能来查看 REST API 调用是如何进行的。