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.
For testing purposes, I was simply using PowerShell to authenticate and get a bearer token with my own credentials in the exact same way that Kay outlined in the Power BI blog post from last month. I would start troubleshooting by making sure you can use your own creds to return data from that dataset using the excecuteQueries endpoint.
You could also try using the "Resolve-PowerBIError -Last" command in PowerShell to see if you can get more information about where the invoke method is going wrong. Just a thought.
I use my cred initially and it didnt work.I also looked at the error but it is not very helpful.
I tried the same exact code few days ago with my creds and it hadnt worked,then i started the SP route.
This is what i get:
- rjhale4 years agoHelper V
At this point I would suggest testing this in Postman. Hopefully, you're familiar enough with Postman to setup a test request. I setup a very basic test on my end like this:
- I used PowerShell to get the bearer token (using my own creds), and then added that to the headers like so:
- I then created a very simple Dax query that I knew would work against this dataset and added it to the Body:
I would think that would give you more information if it continues to fail. Make sure your account has Build permissions to the dataset you're trying to query.
- Anonymous4 years agoNot applicable
Thanks a lot for your help.
I tried in postman but i constantly got the invalid hostname error.
So i switched back to tryig in PS and i wrote a simple DAx same as you and logged in as 'me' and it had worked.
- rjhale4 years agoHelper V
Glad to hear you got that far. Sounds like it may be the result of you Dax syntax. I started using the performance analyzer in Power BI desktop to create my Dax queries.. It's a really quick way of getting the right syntax for the various tables, fields, and aggregations. Just thought I would share that tip.