🧩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 4: Embedding the Power BI Report
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