Kar*_*ngh 4 powerbi service-principal powerbi-api
要求:通过服务主体使用 Powershell 脚本更新 PowerBI 数据集计划。使用 PowerBI API。参考:微软文档
\n错误消息:“消息”:“应用程序无法访问 API”
\n我做了什么:
\n\n将 SP 放入 AD 组中。将此 AD 组设为 Power BI 工作区和数据集的管理员(在 Power BI 管理设置下)
\n使用使用服务主体生成的访问令牌。针对 API 请求调用 RestMethod。
\n$SecPasswd = ConvertTo-SecureString $ClientSecret -AsPlainText -Force\n$ClientCred = New-Object System.Management.Automation.PSCredential($ClientId,$SecPasswd)\n\nConnect-PowerBIServiceAccount -Tenant $tenantId -ServicePrincipal -Credential $ClientCred\n$accessToken = Get-PowerBIAccessToken\n$authHeader = @{\'Content-Type\'=\'application/json\',\'Authorization\'= $accessToken.Authorization}\n$uri="https://api.powerbi.com/v1.0/myorg/datasets/$datasetId/refreshSchedule"\nInvoke-RestMethod -Uri $uri \xe2\x80\x93Headers $authHeader \xe2\x80\x93Method Patch -Body ($jsonBase | ConvertTo-Json) -ContentType "application/json"\n
Run Code Online (Sandbox Code Playgroud)\n观察结果:
\n使用我的工作区的 datasetId 并运行脚本。2个场景:
\nForbidden 403 Error. "Message":"API is not accessible for application
。我缺少哪些权限来使用服务主体更新数据集计划?
\nNei*_*l P 11
Microsoft API 文档中的 URL 对于服务主体来说是错误的。
您还需要在 URL 中包含工作区 ID,请参见下文
https://api.powerbi.com/v1.0/myorg/groups/{WorkspaceID}/datasets/{DatasetId}refreshes
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4311 次 |
最近记录: |