Forum Discussion

SRJPBI's avatar
SRJPBI
Frequent Visitor
3 months ago
Solved

Power BI REST API - why does my cloud connector call fail with 'BadRequest'?

I have a Power BI report that's been published into the online service. It works fine. I now want to automatically extract data from a matrix within the report.   I have created a flow in Power Aut...
  • v-ssriganesh's avatar
    3 months ago

    Hi SRJPBI,

    Thank you for sharing the details and the updated DAX query.

    Based on the official Microsoft documentation, the Execute Queries REST API requires a valid DAX query that returns a table, typically using a single EVALUATE statement. The query pattern you’re using (DEFINE / VAR with one EVALUATE) is valid DAX syntax.

    When using this API from Power Automate, a 400 BadRequest is commonly caused by request‑formatting issues rather than the DAX logic itself:

    • The DAX query is sent inside a JSON request body, so any double quotes inside the DAX (for example "IsGrandTotalRowTotal") must be escaped (e.g., \"IsGrandTotalRowTotal\") to keep the JSON valid.
    • Only the DAX query should be passed to the API; comments such as // DAX Query should be removed.

    Ensure the request body follows the documented format:

    {
      "queries": [
       { "query": "<DAX query text>" }
      ]
    }

    In addition, please verify the documented prerequisites:

    • The Dataset Execute Queries REST API tenant setting is enabled.
    • The calling user has Read + Build permissions on the dataset.

    For troubleshooting, you can also test with a simpler SUMMARIZECOLUMNS query to confirm the API call succeeds before adding more complex logic.

    For your reference: Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn

    Best regards,
    Ganesh Singamshetty