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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. 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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.