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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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?

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

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

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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