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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bfinnegan7675
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!

 

 

 

   try
   {
       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;
     }
     catch
     {
          throw;
     }


 

 

 

 

1 REPLY 1
bfinnegan7675
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

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.