Forum Discussion
New API Endpoint with DAX Queries
- 5 years ago
I finally got this partially worked out with the help of one of the very helpful Power BI engineers. For some reason datasets in My Workspace don't seem to be getting proper build permissions, so I decided to switch to just testing datasets in my v2 workspaces.
I initally thought that I had to use the format https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId} because that is what I'm accustomed to doing. This will probably change as this gets closer to GA, but for now you actually just remove the parts about the group and reference the dataset directly. For example: https://api.powerbi.com/v1.0/myorg/datasets/f388a618-2c93-41c5-8528-44c0c1129d70/executeQueries
Once I made that change, I was able to return data from a Powershell script and Postman. Still not sure about the permssions in My Workspace, but I'll likely never use that anway.
Same error đ„ Would you be able to post your $requestBody?
$requestBody = @"
{âqueriesâ: [{âqueryâ:âEVALUATE SUMMARIZE('Calendar','Calendar'[Year],\"Days in year\",COUNT('Calendar'[Date]))â}], âserializerSettingsâ:{âincudeNullsâ: true}}
"@
The last query that I posted was actually from a Power Automate variable that I was working with. I also tested a different query using Powershell, and here is an example of the $requestBody variable:
$requestBody = @"
{
"queries":
[
{
"query": "
DEFINE
VAR __DS0FilterTable =
TREATAS({\"CHEM\"}, 'Proposals'[DOCUMENT_DEPT_NAME])
VAR __DS0Core =
SUMMARIZECOLUMNS(
'Proposals'[DOCUMENT_ID],
__DS0FilterTable,
\"SumDIRECT_AMT\", CALCULATE(SUM('Proposals'[DIRECT_AMT]))
)
VAR __DS0PrimaryWindowed =
TOPN(501, __DS0Core, 'Proposals'[ID], 1)
EVALUATE
__DS0PrimaryWindowed
ORDER BY
'Proposals'[ID]"
}
]
}
"@@I would also make sure that your double quotes are the correct type of double quotes. I'm not sure if you copy and pasted right from your PS script, but it looks to me like you have two different types of double quotes being used.