Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

New Member

PowerBI C# api throwing Object not set to an instance of an Object on ExportToFileAsync and Group

Hi all,


I'm using the power BI C# web api Version 4.1.13 to export a report from our Power BI Tenant to a PDF.


I'm able to authenticate and get a bearer token successfully, but I'm running into the same error on the ExportToFileAsync and ExportToFileInGroupAsync calls, no matter what I pass it throws this error - System.NullReferenceException: 'Object reference not set to an instance of an object.'


Here's my code, am I missing anything obivous here? This is the first time I've used this API.


Thank you for any help!




       var exportRequest = new ExportReportRequest
         Format = format

       if(_currentAccessToken == null)
          await Authenticate();
      // The 'Client' object is an instance of the Power BI .NET SDK
      var export = await client.Reports.ExportToFileInGroupAsync(reportId, groupId, exportRequest);

         // Save the export ID, you'll need it for polling and getting the exported file
         return export.Id;





New Member

My problem was that I was not awaiting the full call stack, so it was sending my client to the garbage collector.

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.