I'm attempting to use the microsoft power BI API to export a report a PDF file version. I'm able to successfully authenticate power BI with azure and can get a bearer token before making this call.
The ExportToFileInGroupAsync(reportId, groupId, exportRequest) is throwing an 'Object reference not set to an instance of an object error.' on the ExportToFileInGroupAsync line. I tried with ExportToFileAsync and the same thing is happening.
I've verified that the groupId and reportId are correct, if I missed that I would expect it to be a 404 error instead of simply crashing.
Has anyone encountered this before?
//get token - working and grabbing bearer
var tokenCredentials = new TokenCredentials(await GetToken(), "Bearer");
//initiate powerBI Client
client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);
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;
}