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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
BertrandK
New Member

Embed report with Direct Query and APIs

Hello,

I have a question about embedding a report with Direct Query.

I'm using the apis like this :

* first the login api to get the access_token
* then a POST on GenerateToken to get the token, tokenID and expiration date (url : https://api.powerbi.com/v1.0/myorg/groups/<GroupId>/reports/<ReportID>/GenerateToken
* finally a GET on the report to get the embedUrl value. (url : https://api.powerbi.com/v1.0/myorg/groups/<GroupId>/reports/<ReportID>)

But when the report is using Direct Query, I have the structure of the report but an error where it should be datas.

It seems that it's the second api call that is incorrect.
According to the documentation,I should add a datasourceIdentities parameter with a datasource object.
But I don't know where I should find the datasourceType, and connectionDetails server & database values, as I don't have access to the report in the PowerBi app.
 
Thank you for your help.
4 REPLIES 4
BertrandK
New Member

Hello,

We finally managed to embed a report with Direct Query thanks to a colleague.

The steps was :

* first the login api to get the access_token
* then a GET on the report to get the embedUrl value AND the datasetId. (url : https://api.powerbi.com/v1.0/myorg/groups/<GroupId>/reports/<ReportID>)
* finally a POST on GenerateToken to get the token, tokenID and expiration date (url: https://api.powerbi.com/v1.0/myorg/GenerateToken, and NOT https://api.powerbi.com/v1.0/myorg/groups/<GroupId>/reports/<ReportID>/GenerateToken)
In this last API, you have to provide a json like this :

{
  "datasets": [
    {
        "id":"<your dataset ID>",
        "xmlaPermissions": "ReadOnly"
    },
    {
        "id":"<the datasetId you get from the Report Api>",
        "xmlaPermissions": "ReadOnly"
    }
  ],
  "reports": [{
    "id": "<your report ID>",
    "allowEdit": false
  }],
  "targetWorkspaces": [
    {
        "id": "<your group/workspace ID>"
    }
  ]
}


Thanks for your help !

BertrandK
New Member

Thank you for your answer.

I've successfully retrieved datasets with the link you provided.

I try to add theses datasets (of types Sql and SharePointList) in the body of GenerateToken but :

* with the https://api.powerbi.com/v1.0/myorg/GenerateToken , I've got an error "Datasource identity must contain identity blob", which I don't know how to get.

* with the https://api.powerbi.com/v1.0/myorg/groups/<GroupId>/reports/<ReportId>/GenerateToken, I have the response with the token, tokenId and expiration values, but when I try to embed the report I still have errors.

Is there something I'm forgetting to do?
Anonymous
Not applicable

HI @BertrandK,

if you not familiar about the IdentityBlobs structure usage, you can take a look at official document sample about generating an embed token for a Power BI report with a dataset which is connected with DirectQuery to another Power BI dataset :

Embed Token - Generate Token - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

HI @BertrandK,

I'd like to suggest you take a look at dataset related API to get the detail datasource informations:

Datasets - Get Datasources In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.