π§©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.
Last updated
{
"value": {
"userId": "<USER_ID>",
"reportId": "<REPORT_ID>",
"roleNames": ["Role1",βRole2β],
"expiration": "<OPTIONAL_EXPIRATION_DATETIME>"
},
"passPhrase": "TenantSecrePhrase",
"tenancyName": "YourTenantName"
} {
β― β― "result": {
β― β― β― β― "key": "<ENCRYPTED_KEY>"
β― β― },
β― β― "success": true,
β― β― "error": null
} 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) # 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"