Embed Server Reports
Embed Server Reports provides option to render the Reports into other web applications. Follow the below steps to embed server Reports into other web applications.
Getting Embed URL
-
Click the
Actions
button in the Reports grid context menu and selectGet Embed code
of the corresponding Reports to embed. -
By Default,
Saved Views
andComments
are enabled. You can able to disable theSaved Views
orComments
by sliding the Saved Views or Comments button as below. -
Copy the embed URL by clicking the
copy
icon from theGet Embed code
dialog.
Embed using Server Authentication
Embed the copied URL into other web application with the help of the following code snippet.
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<body>
<iframe id="frame-div" width="100%" height="100%" frameborder="0" src="http://localhost:53002/reports/embed/Sample%20Reports/Product%20Line%20Sales?hascomments=true&hasviews=true&hassso=false" onload="apiCall()"></iframe>
<script>
$(document).ready(function() {
jQuery.support.cors = true;
});
function apiCall() {
var dataValue = "";
var element = document.getElementById("frame-div").contentWindow;
var apiRequest = new Object();
var baseURL = "http://localhost:53002"; //Replace here with the launched Report Server site URL
apiRequest.validationKey = ""; //Find the Validation key in MachineKey node of the Report Server web.config file
apiRequest.decryptionKey = ""; //Find the Decryption key in MachineKey node of the Report Server web.config file
apiRequest.userId = "admin"; //Username/UserId of the user who has permission to the particular Report
apiRequest.password = "admin"; //Password of the user. Its optional when validationKey and decryptionKey is used.
$.ajax({
type: "POST",
url: baseURL + "/api/get-user-key",
data: apiRequest,
success: function(data) {
dataValue = data.Token;
element.postMessage(dataValue, "*");
},
error: function(data) {
element.postMessage("", "*");
}
});
}
</script>
</html>
Please find the below changes that have to be done to render the Report into the web application.
- Paste the copied Embed URL instead of the above iframe.
- Add the
apiCall()
function invoke in iframe onLoad event. - Can able to get the token using either by passing the below three type of properties.
a. Username and Password
b. UserId, ValidationKey and DecryptionKey
c. Username, ValidationKey and DecryptionKey
NOTE
Public Reports does not need token to authenticate with Report Server.
Embed using Windows AD Authentication
If the Report Server deployed into the machine which has configured with the Windows Active Directory, then follow the below steps to get the embed code with the Windows Active Directory SSO settings.
-
Click the
Actions
button in the Reports grid context menuGet Embed code
and enable SSO and selectWindows Active Directory
as shown below. -
Paste the embed URL into an web application which has
Windows Active Directory
configuration. -
Run the web application and the Reports will render automatically.
Embed using Azure AD Authentication
If the Report Server deployed into the machine which has configured with the Azure Active Directory, you can follow the below steps to get the embed code with the Azure Active Directory SSO settings.
-
Copy the embed URL from the Reports context menu
Get Embed code
and enable SSO and selectAzure Active Directory
as shown below. -
Paste the embed URL into an web application which has
Azure Active Directory
configuration. -
Run the web application and the Reports will render automatically.