要求:通过服务主体使用 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 | …
Run Code Online (Sandbox Code Playgroud)目标:在powerbi api javascript的帮助下将分页报告加载到几乎没有参数的网页中。
分页 reportUrl:https ://app.powerbi.com/groups/workspaceId/rdlreports/reportId ? ctid = something & rp:CustomerID = something & rp:ContractID = something
我可以加载报告但无法传递参数 - 因此报告加载为空白。
与powerbi 报告不同,分页报告不支持像powerBi 嵌入式报告那样的report.getFilters()。
我参考了这些文档 - 但找不到任何帮助...
https://docs.microsoft.com/en-us/power-bi/paginated-reports-parameters https://docs.microsoft.com/en-us/power-bi/developer/paginated-reports-row-level -security#passing-the-configured-parameter-using-the-embed-token https://docs.microsoft.com/en-us/power-bi/developer/embed-paginated-reports-customers
这就是我获取 powerbi 报告然后将其嵌入网页的方式:
[HttpGet]
[Route("AccessToken")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult> GetEmbeddedAccessTokenAsync(string reportType)
{
Guid currentReportId = getCurrentReportId(reportType); //private method which gets the report guid
using (var client = await GetPowerBIClientAsync())
{
var report = await client.Reports.GetReportInGroupAsync(_powerBiWorkspaceId, currentReportId);
var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: TokenAccessLevel.View);
var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(_powerBiWorkspaceId, report.Id, …
Run Code Online (Sandbox Code Playgroud)