Power BI REST API ExportToFileInGroup 不工作
Power BI REST API ExportToFileInGroup Not Working
我能够以编程方式登录 PowerBI Client, gather my Workspaces as well as get a specific Report from a specific Workspace. I need to programmatically render that report to a .pdf or .xlsx file. Allegedly this is possible with the ExportToFileInGroup
/ExportToFileInGroupAsync
methods. I even created a very simple report without any parameters. I can embed this using the sample app from here。所以这至少告诉我我在后端有我需要的设置。但是当我尝试 运行 ExportToFileInGroupAsync
方法时它失败了(代码下面的错误。)
我的密码是:
var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(new string[] {
PowerBiScopes.ReadReport,
PowerBiScopes.ReadDataset,
});
var userInfo = await graphServiceClient.Me.Request().GetAsync();
var userName = userInfo.Mail;
AuthDetails authDetails = new AuthDetails {
UserName = userName,
AccessToken = accessToken,
};
var credentials = new TokenCredentials($"{accessToken}", "Bearer");
PowerBIClient powerBIClient = new PowerBIClient(credentials);
var groups = await powerBIClient.Groups.GetGroupsAsync();
var theGroup = groups.Value
.Where(x => x.Name == "SWIFT Application Development")
.FirstOrDefault();
var groupReports = await powerBIClient.Reports.GetReportsAsync(theGroup.Id);
var theReport = groupReports.Value
.Where(x => x.Name == "No Param Test")
.FirstOrDefault();
var exportRequest = new ExportReportRequest {
Format = FileFormat.PDF,
};
string result = "";
try {
var response = await powerBIClient.Reports.ExportToFileInGroupAsync(theGroup.Id, theReport.Id, exportRequest);
result = response.ReportId.ToString();
} catch (Exception e) {
result = e.Message;
}
return result;
它到达 try
块中的行,然后抛出以下错误:
发送请求时出错。
无法从传输连接读取数据:现有连接被远程主机强制关闭..
更新
关于@AndreyNikolov 问题,这是我们的嵌入式容量:
实施后,没有变化。完全相同的错误。
原来问题出在我们这边,更具体地说,security/firewall 设置。这是我们网络大师的原话。
“经过更多调查,我们确定是我们的防火墙在终止 SSL 连接时导致了这个问题。我们能够为 URL 添加绕过,现在按预期工作。"
我能够以编程方式登录 PowerBI Client, gather my Workspaces as well as get a specific Report from a specific Workspace. I need to programmatically render that report to a .pdf or .xlsx file. Allegedly this is possible with the ExportToFileInGroup
/ExportToFileInGroupAsync
methods. I even created a very simple report without any parameters. I can embed this using the sample app from here。所以这至少告诉我我在后端有我需要的设置。但是当我尝试 运行 ExportToFileInGroupAsync
方法时它失败了(代码下面的错误。)
我的密码是:
var accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(new string[] {
PowerBiScopes.ReadReport,
PowerBiScopes.ReadDataset,
});
var userInfo = await graphServiceClient.Me.Request().GetAsync();
var userName = userInfo.Mail;
AuthDetails authDetails = new AuthDetails {
UserName = userName,
AccessToken = accessToken,
};
var credentials = new TokenCredentials($"{accessToken}", "Bearer");
PowerBIClient powerBIClient = new PowerBIClient(credentials);
var groups = await powerBIClient.Groups.GetGroupsAsync();
var theGroup = groups.Value
.Where(x => x.Name == "SWIFT Application Development")
.FirstOrDefault();
var groupReports = await powerBIClient.Reports.GetReportsAsync(theGroup.Id);
var theReport = groupReports.Value
.Where(x => x.Name == "No Param Test")
.FirstOrDefault();
var exportRequest = new ExportReportRequest {
Format = FileFormat.PDF,
};
string result = "";
try {
var response = await powerBIClient.Reports.ExportToFileInGroupAsync(theGroup.Id, theReport.Id, exportRequest);
result = response.ReportId.ToString();
} catch (Exception e) {
result = e.Message;
}
return result;
它到达 try
块中的行,然后抛出以下错误:
发送请求时出错。
无法从传输连接读取数据:现有连接被远程主机强制关闭..
更新
关于@AndreyNikolov 问题,这是我们的嵌入式容量:
实施后,没有变化。完全相同的错误。
原来问题出在我们这边,更具体地说,security/firewall 设置。这是我们网络大师的原话。
“经过更多调查,我们确定是我们的防火墙在终止 SSL 连接时导致了这个问题。我们能够为 URL 添加绕过,现在按预期工作。"