Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
naam_nrj
Regular Visitor

Embed report with SQL database as data source

Hi
I have embedded my report in edit mode using service principal. I am able to edit and save reports whose data source is excel file. However, I am getting status 400 error when I try to embed report whose data comes directly from SQL database.

Is there any different method for these reports? Do I need any other permission or access to embed these reports?

I am using only import mode for my report and the code is from PowerBI-Developer-Samples repo from microsoft:

https://github.com/microsoft/PowerBI-Developer-Samples

 

Error:

naam_nrj_0-1712150597738.png

Body of API call:

 

 

{
reports: [ { allowEdit: true, id: '<my report id>' } ],
datasets: [ {id: '<my dataset id>'} ],
targetWorkspaces: [ { id: '<workspace id>' } ]
}

 

 

 

Code where it generates embed token:

 

 

const embedTokenApi = "https://api.powerbi.com/v1.0/myorg/GenerateToken";
const headers = await getRequestHeader();

console.log("======Body=========\n", formData)

// Generate Embed token for single report, workspace, and multiple datasets. Refer https://aka.ms/MultiResourceEmbedToken
const result = await fetch(embedTokenApi, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(formData)
});

 

 

Error I am facing:

 

 

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _events: [Object],
      _readableState: [ReadableState],
      _writableState: [WritableState],
      allowHalfOpen: true,
      _maxListeners: undefined,
      _eventsCount: 5,
      [Symbol(shapeMode)]: true,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: null
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://api.powerbi.com/v1.0/myorg/GenerateToken',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

 

 

 

2 REPLIES 2
naam_nrj
Regular Visitor

Hi @v-shex-msft 

I have update the question with more details.

I am using semantic model and import mode to get data from database.

I have exactly what the documentation says. Still I am unable to retrieve the embed keys.

I did not find any topic like this on the internet so I am not sure what's the cause of this error.

Reports with excel data as data source are working fine.

While I tried asking gemini for this, it suggests to give my service principal the admin acces to my SQL database. I doubt if its the right solution so I thought lets ask professionals.

 

v-shex-msft
Community Support
Community Support

HI @naam_nrj,

What type of connection more are you worked? Please share some more detailed information to help us clarify them and troubleshoot.

How to Get Your Question Answered Quickly  

In addition, you can also take a look at the official document limitation list if they meet to your scenario:

Embed Power BI content in an embedded analytics application with service principal and an applicatio...

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.