Forum Discussion
Want to add Export Power BI Report Feature in my application where in embed the report
- 6 years ago
You will have to implement the asynchronous process described in the documentation. Your app needs to call the API with the export request, receive the job ID, then your app needs to poll the API with the job ID for the render status, and once rendering is complete, your app can then download the resulting blob and offer it to the app users for their download etc.
You will have to implement the asynchronous process described in the documentation. Your app needs to call the API with the export request, receive the job ID, then your app needs to poll the API with the job ID for the render status, and once rendering is complete, your app can then download the resulting blob and offer it to the app users for their download etc.
- saadashraf6 years ago
Helper I
Thanks for responding Ibendlin. I really appreciate that.
Can you please tell me which documentation you are reffering here for asynchronous process ?
- lbendlin6 years ago
Super User
- saadashraf6 years ago
Helper I
Hi Ibendlin,
By using the referred document, i tried to export a power bi report from my application using this code.
var powerBIReportExportConfiguration = new PowerBIReportExportConfiguration
{
Settings = new ExportReportSettings
{
Locale = "en-us",
},
Pages = pageNames?.Select(pn => new ExportReportPage(pageName = pn)).ToList(),
};
var exportRequest = new ExportReportRequest
{
Format = format,
PowerBIReportConfiguration = powerBIReportExportConfiguration,
};var url = XXX;
var content = new Dictionary<string, string>();
content["grant_type"] = "XXX";
content["resource"] = "XXX";
content["username"] = XXX;
content["password"] = XXX;
content["client_id"] = XXX;var response = await APIHelper.MakeAsyncRequest(url, content);
var tokenresult = response.Content.ReadAsStringAsync().Result;
var OAuthResultModel = JsonConvert.DeserializeObject<OAuthResultModel>(tokenresult);
var authenticationResult = OAuthResultModel;var credentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
var client = new PowerBIClient(credentials);
var reportsResult = await client.Reports.ExportToFileInGroupAsync(GroupID, ReportID, exportRequest);
While executing the last line, code break and through an exception, i.e.:{"Operation returned an invalid status code 'Forbidden"}