Forum Discussion
New API Endpoint with DAX Queries
- 4 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.
And jhayes0128. I also noted that in your code, you are not only using straight quotes (sorry for the probably not fully correct term). You should use " and not “ or ”.
Here is my simple request body:
# Here comes the DAX query wrapped in the request body.
# Using @" "@ makes the text literal, which is much easier
# Not that " in the DAX query must be preceeded by a \
# Port Calls Query - List ship count per country code
$requestBody = @"
{
"queries":
[
{"query":
"EVALUATE SUMMARIZECOLUMNS(
'Movements'[countryCode],
\"Ship Count\", [shipCount]
)"
}
],
"serializerSettings":{"incudeNulls": true}}
"@
You are my hero Anonymous !!!! IT WORKS!
I never would've guessed this fix. thank you thank you thank you!!!