Forum Discussion
Recieving (403) Forbidden when Accessing Dataset via API
Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.
At line:1 char:2
+ Invoke-WebRequest -Uri $url -Method Post -Body $body -Headers $heade ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand- ibarrau2 years agoSuper User
Alright 401 might be different. Make sure the permissions of the registered app at azure have "Dataset.ReadWrite.All" or "Dataset.Read.All".
If you can see the Admin portal or ask for IT department. Please check this setting:
I hope that helps,
- MikeFleming2 years agoRegular Visitor
Hi, yes,
- ibarrau2 years agoSuper User
This might sound weird but please remove the Grant admin consent to the permissions. That's a permission for tenant only that can produce error for regular api requests.
Also add Dataset.ReadWrite.All to keep both permissions for dataset.
Just in case, let's sync something. You are using executeQueries. The request is asking for DAX Query in "My Workspace". If you want to query a dataset in a workspace you must use executeQueries in Group.
Please test "Get Datasets in Group" and let us know if that one works.
Make sure you are not breaking a limitation: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries-in-group#limitations
Regards.