Forum Discussion
Help Needed with Power BI App Owns Data Integration in Node.js App - 400 Bad Request Error
Hello fellow Power BI enthusiasts,
I'm reaching out to the community in search of some much-needed assistance with a Power BI integration issue that has been giving me sleepless nights for the past four days. Any help or insights would be greatly appreciated!
Background: I've been working on a Power BI integration in a Node.js app, and initially, everything was running smoothly. However, I recently encountered a problem when I attempted to change the embedded report. Since then, I've been consistently getting a frustrating "400 Bad Request" error, and I'm at my wit's end trying to resolve it.
Here are some additional details:
I'm using a Premium Per User License for this integration.
To facilitate authentication, I've set up a service principal and a security group, and they've been added to the workspace for access.
Following the official documentation (https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=net-core#step-6---service-principal-api-access), I've allowed Power BI access in the Power BI admin portal.
This integration is built using Node.js, and it was functioning perfectly fine until I tried to embed another report.
All the necessary details, including the report ID, workspace ID, etc., are correctly configured in my config.json
file.The error seems to originate from within the getEmbedTokenForSingleReportSingleWorkspace
function, particularly in the fetch request to obtain the embed token:
const result = await fetch(embedTokenApi, {
method: 'POST',
headers: headers,
body: JSON.stringify(formData)
});
I'm genuinely stumped by this issue and have been trying to troubleshoot it for days without success. If anyone has encountered a similar problem or has expertise in Power BI integration with Node.js, I would be immensely grateful for any insights, suggestions, or solutions you can offer.
1 Reply
- AnonymousNot applicable
Hi rkb2023 ,
According to your description, it seems that you got 400 bad request error when you embed for custom using Node.js method. And it occurred at getting the token. It may be caused by many reasons, please check the following info:
- Incorrect API Call: Ensure that you’re making the correct API call. For example, your calling URL should be “https://api.powerbi.com/v1.0/myorg/GenerateToken” and the dataset and report id should be contained in the body.
Permission tokens needed for embedding a Power BI app - Power BI | Microsoft Learn
- Row-Level Security (RLS): If you’re using the ‘App owns data’ type of embedding and using the Service Principal to generate embedding tokens, then the Identity section of the token request should contain details of the ‘user’ used for Row Level Security purposes.
Solved: 400 Bad Request Error when embedding report - Microsoft Fabric Community
- Headers: Ensure that you have set the correct headers in your API call.
Solved: PowerBI API - 400 Bad Request - On postman - Microsoft Fabric Community
- Permissions: Make sure that you have the necessary permissions to access the data
Best Regards
- Incorrect API Call: Ensure that you’re making the correct API call. For example, your calling URL should be “https://api.powerbi.com/v1.0/myorg/GenerateToken” and the dataset and report id should be contained in the body.