Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello All,
I am properly stumped and would be overjoyed if someone could help me solve this puzzle or let me know if it is not supported currently in the api. Was not able to find too much about this is the documentation or prior posts.
Developer Tool: Power BI API SDK v4.16
Error Message: RootActivityId(2ac22f10-46b4-4e15-bfed-330412c421c3): Some parameters do not have valid values. Values provided for participantId that are not valid include a939e322-9134-48ad-ae96-afa4017322e5."
Repro Steps:
I've sanity checked the following
I've spent more time than I care to admit on this and was wondering if anyone has solved something similar in the past?
Relevant Code :
async Task<Document> ExportPowerBIPaginatedReport(PowerBIReport powerBIReport)
{
var exportId = await PostExportRequest(powerBIReport.WorkspaceId.Value, powerBIReport.ExternalReportId.Value, powerBIReport.TenantId);
var export = await PollExportRequest(powerBIReport.ExternalReportId.Value, powerBIReport.WorkspaceId.Value, exportId);
var exportedFile = await GetExportedFile(powerBIReport.ExternalReportId.Value, powerBIReport.WorkspaceId.Value, export);
//save to temp for now, eventually would just return and save to documents like in SSRSReportManager
using (FileStream fileStream = new FileStream("C:\\temp\\tester.pdf", FileMode.Create, FileAccess.Write))
{
// Write the bytes to the file
fileStream.Write(exportedFile.Content, 0, exportedFile.Content.Length);
}
return exportedFile;
}
private async Task<string> PostExportRequest(Guid groupId, Guid reportId, Guid tenantId)
{
using (var client = await GetPowerBiClient())
{
var testGuid = new Guid("A939E322-9134-48AD-AE96-AFA4017322E5");
var paginatedReportExportConfiguration = new PaginatedReportExportConfiguration()
{
ParameterValues = new List<ParameterValue>()
{
{ new ParameterValue() {Name = "tenantId", Value = tenantId.ToString() } },
{ new ParameterValue() {Name = "participantId", Value = testGuid.ToString() } },
{ new ParameterValue() {Name = "asOfDate", Value = DateTime.Now.ToString() } },
},
};
var exportRequest = new ExportReportRequest
{
Format = FileFormat.PDF,
PaginatedReportConfiguration = paginatedReportExportConfiguration,
};
var export = await client.Reports.ExportToFileInGroupAsync(groupId, reportId, exportRequest);
// Save the export ID, you'll need it for polling and getting the exported file
return export.Id;
}
}
private async Task<Export> PollExportRequest(Guid reportId, Guid groupId, string exportId)
{
using (var client = await GetPowerBiClient())
{
Export exportStatus = null;
DateTime startTime = DateTime.UtcNow;
const int secToMillisec = 1000;
HttpOperationResponse<Export> httpMessage;
do
{
//eventually we'd want to set a timeout here and potentially the ability to cancel
/*if (DateTime.UtcNow.Subtract(startTime).TotalMinutes > timeOutInMinutes || token.IsCancellationRequested)
{
// Error handling for timeout and cancellations
return null;
}*/
httpMessage = await client.Reports.GetExportToFileStatusInGroupWithHttpMessagesAsync(groupId, reportId, exportId);
exportStatus = httpMessage.Body;
if (exportStatus.Status == ExportState.Running || exportStatus.Status == ExportState.NotStarted)
{
// The recommended waiting time between polling requests can be found in the RetryAfter header
// Note that this header is only populated when the status is either Running or NotStarted
var retryAfter = httpMessage.Response.Headers.RetryAfter;
var retryAfterInSec = retryAfter.Delta.Value.Seconds;
await Task.Delay(retryAfterInSec * secToMillisec);
}
}
// While not in a terminal state, keep polling
while (exportStatus.Status != ExportState.Succeeded && exportStatus.Status != ExportState.Failed);
if (exportStatus.Status == ExportState.Failed)
{
// Error handling for failure, set the failure message of the report history
var content = httpMessage.Response.Content;
var error = await content.ReadAsStringAsync();
var test = httpMessage.Response;
//pause here to see error message
}
return exportStatus;
}
}
private async Task<Document> GetExportedFile(Guid reportId, Guid groupId, Export export)
{
using (var client = await GetPowerBiClient())
{
if (export.Status == ExportState.Succeeded)
{
byte[] content;
var httpMessage =
await client.Reports.GetFileOfExportToFileInGroupWithHttpMessagesAsync(groupId, reportId, export.Id);
using (MemoryStream newMemoryStream = new MemoryStream())
{
httpMessage.Body.CopyTo(newMemoryStream);
content = newMemoryStream.ToArray();
}
return new Document
{
Content = content,
Name = export.ReportName,
FileType = export.ResourceFileExtension,
};
}
return null;
}
}