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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
tech49
New Member

PowerBI API not running query from executeQueries endpoint

Hi, 

I'm connecting fine to the PowerBI API however I can't run DAX queries.   My end game is to assit the process of ascertaining what datasources and tables are used by what PowerBI reports.

 

I'm using the following endpoint as shown from Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn:

 
https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries 

 

I'm sending the following JSON to the API: 

{
    "queries": [
        "select * from $SYSTEM.TMSCHEMA_PARTITIONS"
    ],
    "serializerSettings": {
        "includeNulls": false
    },
    "impersonatedUserName": null
}

I'm getting the following error...

"message":"Error converting value \"select * from $SYSTEM.TMSCHEMA_PARTITIONS\" to type 'Microsoft.InfoNav.Explore.ServiceContracts.Internal.ExecuteDatasetQuery

 

 

 

1 ACCEPTED SOLUTION

HI @tech49,

As the document mentions, current this API only support to send Dax query and T-SQL query should not be suitable for this API usages:

Executes Data Analysis Expressions (DAX) queries against the provided dataset. The dataset must reside in My workspace or another workspace.

Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Data Analysis Expressions (DAX) Reference - DAX | 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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Given your end game is to ascertain datasource and tables per report, assuming you want something to run across the whole tenant. If this is the case, you would be better served using the Scanner APIs.


All of the following can be obtained from GetScanResult:

 

Datasets will give you Tables and Datasources (Tables is simply 'tables, Datasources, you will get from datasourceUsages[datasourceInstanceId].

 

There are many ways you can get to this data, depending on your preference. Personally, I've extended this solution Extracting Power BI metadata with Data Factory (part 1) – justB smart but if you don't need to store the data, the Power BI REST API Connector is much faster to get running Power BI REST API Connector — The Power User.

 

With your datasourceInstanceId you can related datasets to datasourceInstances (this will then give you more details about that particular datasource.

 

You can then use reports[datasetid] to link all the above back to your report.

 

Admin - WorkspaceInfo GetScanResult - REST API (Power BI Power BI REST APIs) | Microsoft Learn

tech49
New Member

Ok, 

I found the first part of my problem, I serialised the JSON incorrectly. 

I should have labelled the as a "query", as below

 

{
    "queries": [
       "query": "select * from $SYSTEM.TMSCHEMA_PARTITIONS"
    ],
    "serializerSettings": {
        "includeNulls": false
    },
    "impersonatedUserName": null
}

 

using that format, I can send a query, however I can't get a TMSCHEMA_PARTITIONS, Now I'm getting 

DataExtensionError, AnalysisServicesErrorCode

HI @tech49,

As the document mentions, current this API only support to send Dax query and T-SQL query should not be suitable for this API usages:

Executes Data Analysis Expressions (DAX) queries against the provided dataset. The dataset must reside in My workspace or another workspace.

Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Data Analysis Expressions (DAX) Reference - DAX | 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
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.