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
Actionsbutton in the Reports grid context menu and selectGet Embed codeof the corresponding Reports to embed.
-
By Default,
Saved ViewsandCommentsare enabled. You can able to disable theSaved ViewsorCommentsby sliding the Saved Views or Comments button as below.
-
Copy the embed URL by clicking the
copyicon from theGet Embed codedialog.
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
Actionsbutton in the Reports grid context menuGet Embed codeand enable SSO and selectWindows Active Directoryas shown below.
-
Paste the embed URL into an web application which has
Windows Active Directoryconfiguration. -
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 codeand enable SSO and selectAzure Active Directoryas shown below.
-
Paste the embed URL into an web application which has
Azure Active Directoryconfiguration. -
Run the web application and the Reports will render automatically.