Get the report ID and dataset ID of the report/dataset you want to get the query for. You can do this by opening the report in Power BI Desktop and then looking at the URL in the address bar. The report ID and dataset ID will be in the URL, separated by a "/".
Use the Power BI REST API to get the query for the report/dataset. The following request will get the query for the report with the ID "reported"
GET https://api.powerbi.com/v1.0/myReportId/datasets/myDatasetId/queries
This request will return a JSON object with the following properties:
- id: The ID of the query.
- name: The name of the query.
- text: The text of the query.
- parameters: An array of objects that represent the parameters of the query. Each object has the following properties:
- name: The name of the parameter.
- value: The value of the parameter.
- Once you have the query, you can execute it by using the Power BI REST API to run a query. The following request will run the query with the ID "myQueryId"
POST https://api.powerbi.com/v1.0/myReportId/datasets/myDatasetId/queries/myQueryId/run
Impact Windows
This request will return a JSON object with the following properties:
- data: The results of the query.
- errors: An array of objects that represent any errors that occurred while running the query. Each object has the following properties:
- message: The error message.
- severity: The severity of the error.
I hope this helps!