Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

PowerBIClient gets Groups and Reprots but Fails on ExportToFileInGroupAsync

I am able to successfully connect to and run some methods using the PowerBIClient.  However, when I try to actually render the paginated report I get an exception of "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."

 

Here is the full code:

 

 

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 swiftGroup = groups.Value
	.Where(x => x.Name == "SWIFT Application Development")
	.FirstOrDefault();

var swiftReports = await powerBIClient.Reports.GetReportsAsync(swiftGroup.Id);
var s0AuditSheet = swiftReports.Value
	.Where(x => x.Name == "S0 A - Audit Sheet")
	.FirstOrDefault();

var paginatedReportExportConfiguration = new PaginatedReportExportConfiguration {
	ParameterValues = new ParameterValue[] {
		new ParameterValue { Name = "OSCode", Value = "9477"},
	},
	Identities = new List<EffectiveIdentity> { 
		new EffectiveIdentity { Username = "kevin.grigsby@lubrizol.com" },
	}
};

var exportRequest = new ExportReportRequest {
	Format = FileFormat.PDF,
	PaginatedReportConfiguration = paginatedReportExportConfiguration,
};

Export result = null;

try {
	result = await powerBIClient.Reports.ExportToFileInGroupAsync(swiftGroup.Id, s0AuditSheet.Id, exportRequest);
} catch (Exception e) {
	string b = e.Message;
}

return result.Id;

 

 

It gets all the way to the `try` block on the ExportToFileInGroupAsync and then fails with:

 

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

 

If I go here and click the Try It button I get a 202 response code and the expected output.  What is the problem here?

 

If I need to tack on an EffectiveIdentity or something else I need to see actual code please.  I have been pulling out my hair trying to get this last bit to work for a week now.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Turns out the issue was on our side, more specifically, security/firewall settings. Here is the exact quote from our networking guru.

 

"After some more investigation we determined that our firewall was causing this issue when it was terminating the SSL connection. We were able to add a bypass for the URL and it is now working as expected."

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Turns out the issue was on our side, more specifically, security/firewall settings. Here is the exact quote from our networking guru.

 

"After some more investigation we determined that our firewall was causing this issue when it was terminating the SSL connection. We were able to add a bypass for the URL and it is now working as expected."

Anonymous
Not applicable

Hi @Anonymous ,

Please refer this official documentation to update the codes as below and check whether you can get the expected result.

....
try {
result = await Client.Reports.ExportToFileInGroupAsync (swiftGroup.Id, s0AuditSheet.Id, exportRequest);
} catch (Exception e) {
string b = e.Message;
}

return result.Id;

If you still can't get the expected result, please use the following methods to get the error log and share it with us in order to make troubleshooting.

1. F12

yingyinr_0-1621590512741.png

2. Use fiddler

Test Web API using Fiddler

Best Regards

Anonymous
Not applicable

I am using Blazor here which seems to block/hide those requests.  I have a more detailed and latest info here at Stack Overflow.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.