🧩ISV for Report Embedding

This guide covers embedding a DataCentral report into a third-party app or website using the REST API and an encrypted key.

Content

Step 1: Setting up the API request

Step 2: Constructing the POST payload

Step 3: Sending the Request

Step 4: Embedding the Power BI Report

Security and Best Practices

Additional Notes

Examples

Overview

What steps are needed to embed a report from a DataCentral tenant into a 3rd party application or website using the REST API endpoint provided by the DataCentral SaaS solution. This will involve sending a POST request to the API to receive an encrypted key, which will then be used to embed the report.

Step 1: Setting up the API request

  • Endpoint: https://apim.datacentral.ai/dcai/encrypter

  • Method: POST

  • Required Querystring Parameter: key=fd049aba32334c95a761abfd8b65723d

Step 2: Constructing the POST payload

Prepare a JSON payload with the following structure:

{ 
    "value": { 
        "userId": "<USER_ID>", 
        "reportId": "<REPORT_ID>", 
        "roleNames": ["Role1",”Role2”], 
        "expiration": "<OPTIONAL_EXPIRATION_DATETIME>" 
    }, 
    "passPhrase": "TenantSecrePhrase", 
    "tenancyName": "YourTenantName" 
} 
  • Replace <USER_ID> with the customer's unique user ID (Kennitala) that will be the value of the DAX UserName() function.

  • Set <REPORT_ID> should uniquely identify a report on website.

  • Set <OPTIONAL_EXPIRATION_DATETIME> with the desired expiration time for the session, example date-time format: "2025-12-18T20:22".

  • The roleNames is a comma separated list of role names to be applied to the model.

The passPhrase can be found on your tenant under Settings-Security, see screenshot below:

Step 3: Sending the request

  • Use a server-side method to send the POST request to ensure security.

  • The request should return a JSON object. If successful, you will receive a response in the following format:

{ 
β€― β€― "result": { 
β€― β€― β€― β€― "key": "<ENCRYPTED_KEY>" 
β€― β€― }, 
β€― β€― "success": true, 
β€― β€― "error": null 
} 
  • Extract <ENCRYPTED_KEY> from the response for embedding the report.

Step 4: Embedding the Power BI Report

  • Replace <ENCRYPTED_KEY> with the key received from the API response.

  • Embed this URL in an iframe on the desired page of our website.

Note in this example the value 1 is the report ID being displayed.

See following picture.

Security and best practices

  • Ensure all API calls are made securely from the server-side to protect the API key and other sensitive data.

  • Validate and sanitize all inputs to prevent security vulnerabilities.

  • Test the implementation thoroughly to ensure the embedded report functions correctly and adheres to the specified role and expiration constraints.

Additional notes

  • The <USER_ID> should uniquely identify a customer on website.

  • The <REPORT_ID> should uniquely identify a report on website.

  • The roleNames array can contain multiple roles if necessary. In this setup, it contains a single role: KennitalaRLS.

  • The <OPTIONAL_EXPIRATION_DATETIME> parameter is optional but recommended to align with the duration of a login session for security reasons.

Examples

Example in Python

import requests 

from flask import Flask, render_template_string 

app = Flask(__name__) 

@app.route('/') 

def embed_power_bi_report(): 

β€― β€― # API endpoint and payload 
β€― β€― url = 'https://apim.datacentral.ai/dcai/encrypter?key=fd049aba32334c95a761abfd8b65723d' 

β€― β€― payload = { 
β€― β€― β€― β€― "value": { 
β€― β€― β€― β€― β€― β€― "userId": "1809742969", β€―# Replace with dynamic user ID as needed 
         "reportId": "7", β€―# Replace with report ID  
β€― β€― β€― β€― β€― β€― "roleNames": ["KennitalaRLS"], 
β€― β€― β€― β€― β€― β€― "expiration": "2024-12-18T20:22" β€―# Adjust expiration as needed 
β€― β€― β€― β€― }, 
β€― β€― β€― β€― "passPhrase": "rhxsukgbw", 
β€― β€― β€― β€― "tenancyName": "kort" 
β€― β€― } 

β€― β€― # Send POST request 

β€― β€― response = requests.post(url, json=payload) 
β€― β€― response_data = response.json() 

β€― β€― # Extract encrypted key 
β€― β€― encrypted_key = response_data['result']['key'] 

β€― β€― # Construct iframe source URL 
  β€― iframe_src = f"https://kort.demo.datacentral.ai/report/7?ev={encrypted_key}" 

 β€― # HTML template with iframe 
β€― β€― html_template = f""" 
β€― β€― <html> 
β€― β€― <head> 
β€― β€― β€― β€― <title>Power BI Report</title> 
β€― β€― </head> 
β€― β€― <body> 
β€― β€― β€― β€― <iframe src="{iframe_src}" width="800" height="600"></iframe> 
β€― β€― </body> 
β€― β€― </html> 
β€― β€― """ 
β€― β€― return render_template_string(html_template)  

if __name__ == '__main__': 
β€― β€― app.run(debug=True) 

Example in Powershell

# Define the API endpoint and the payload 

$ApiEndpoint = "https://apim.datacentral.ai/dcai/encrypter?key=fd049aba32334c95a761abfd8b65723d" 

$Payload = @{ 
β€― β€― value = @{ 
β€― β€― β€― β€― userId = "1809742969" β€―# Replace with the actual user ID 
  	  reportId = "7" β€―# Replace with the actual user ID 
β€― β€― β€― β€― roleNames = @("KennitalaRLS") 
β€― β€― β€― β€― expiration = "2025-12-18T20:22" β€―# Adjust the expiration date as needed 
β€― β€― } 
β€― β€― passPhrase = "rhxsukgbw" 
β€― β€― tenancyName = "kort" 
} 

# Convert the payload to JSON 
$JsonPayload = $Payload | ConvertTo-Json 
 
# Make the POST request 
$Response = Invoke-RestMethod -Uri $ApiEndpoint -Method Post -Body $JsonPayload -ContentType "application/json" 

# Extract the encrypted key from the response 
$EncryptedKey = $Response.result.key 

# Print the report URL with the encrypted key 
Write-Host "https://kort.demo.datacentral.ai/report/7?ev=$EncryptedKey" 

Example in Postman / Insomnia

Last updated