Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I published below report in powerbi server by updating latest SessionId & BaseURL based on Client's interaction from webpage.
Solved! Go to Solution.
Hi, @ViralGajjar2904
Here is a sample API call to generate an embed token:
import requests
import json
def generate_embed_token(username, report_id, dataset_id, workspace_id):
url = "https://api.powerbi.com/v1.0/myorg/reports/{report_id}/GenerateToken"
payload = json.dumps({
"accessLevel": "View",
"identities": [
{
"username": username,
"roles": ["Viewer"],
"datasets": [dataset_id]
}
]
})
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url.format(report_id=report_id), headers=headers, data=payload)
if response.status_code == 200:
return response.json()['token']
else:
raise Exception(f"Error generating embed token: {response.text}")
# Example usage:
embed_token = generate_embed_token("user@example.com", "report_id", "dataset_id", "workspace_id")
Ensure that your embedded report uses the token generated for the specific user session. This can be done in your client-side code where the Power BI report is embedded:
var embedToken = 'USER_SPECIFIC_EMBED_TOKEN';
var reportId = 'YOUR_REPORT_ID';
var groupId = 'YOUR_GROUP_ID';
var embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${reportId}&groupId=${groupId}`;
var models = window['powerbi-client'].models;
var embedConfig = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, embedConfig);
Use different browser sessions or incognito windows to simulate multiple users accessing the report. Ensure that each session generates and uses a unique embed token.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Hi, @ViralGajjar2904
The main reason for this problem is that power BI caches parameters and provides the latest values. When you open two websites, the two refresh operations are very close and there is a progress bar, which will cause the report to pick up parameters from the last trigger.
You can consider: generating a new token for each session to ensure that the data is isolated.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Hi @hackcrr
should I have to generate unique embed token for user wise?
I already configured code for generate embed token, but I do not have multi users for testing purpose.
I am aceessing reports form both websites (n20.netzoom.com & 20.netzoom.com) via Single user, so it might be cretae above problem? I am not sure...!
Could you please suggets how to use embed token once generated.
Hi, @ViralGajjar2904
Here is a sample API call to generate an embed token:
import requests
import json
def generate_embed_token(username, report_id, dataset_id, workspace_id):
url = "https://api.powerbi.com/v1.0/myorg/reports/{report_id}/GenerateToken"
payload = json.dumps({
"accessLevel": "View",
"identities": [
{
"username": username,
"roles": ["Viewer"],
"datasets": [dataset_id]
}
]
})
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url.format(report_id=report_id), headers=headers, data=payload)
if response.status_code == 200:
return response.json()['token']
else:
raise Exception(f"Error generating embed token: {response.text}")
# Example usage:
embed_token = generate_embed_token("user@example.com", "report_id", "dataset_id", "workspace_id")
Ensure that your embedded report uses the token generated for the specific user session. This can be done in your client-side code where the Power BI report is embedded:
var embedToken = 'USER_SPECIFIC_EMBED_TOKEN';
var reportId = 'YOUR_REPORT_ID';
var groupId = 'YOUR_GROUP_ID';
var embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${reportId}&groupId=${groupId}`;
var models = window['powerbi-client'].models;
var embedConfig = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, embedConfig);
Use different browser sessions or incognito windows to simulate multiple users accessing the report. Ensure that each session generates and uses a unique embed token.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |