Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
AmilaGunawardan
Frequent Visitor

Power BI Rest API Refresh Dataset gives 404 error

HI,

I have created a PowerShell file to refresh the automation of a Power BI dataset. This below snippet worked for a few days and suddenly gave the below error.

VERBOSE: POST https://api.powerbi.com/v1.0/myorg/groups/5fa2e3dc-f8a1-44f1-8f8a-836a531bb0fd/datasets/c9d43a1c-ab7b-4db0-ad72-ce63f9057c69/refreshes with 0-byte payload
Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At line:27 char:15
+ ... esultJson = Invoke-RestMethod -Uri $pbiURLapps -Method Post -Headers  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
 

Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27

 

The code that I have used as stated below.

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword

##Connecting PowerBI
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -Tenant $TenantID

$datasetID = "<DSid>"
$groupID =  "<gpid>"

$pbiURLapps = "https://api.powerbi.com/v1.0/myorg/groups/$groupID/datasets/$datasetID/refreshes"

$header = Get-PowerBIAccessToken

$resultJson = Invoke-RestMethod -Uri $pbiURLapps -Method Post -Headers $header  -Verbose

 

I can confirm that dataset ID and group ID is correct. and i have used service principle to do the refresh. Thank you in advance.

2 ACCEPTED SOLUTIONS
AmilaGunawardan
Frequent Visitor

This was fixed by adding the relevant AD group to the workspace as a member. 

View solution in original post

This error happened because the service principle access got revoked without a warning.

View solution in original post

8 REPLIES 8
AmilaGunawardan
Frequent Visitor

This was fixed by adding the relevant AD group to the workspace as a member. 

AmosHersch
Employee
Employee

Seems that your service principal lost access to the dataset

Hey, In case if the access is lost the error messgae would be unauthorized access (401) and not 404.

404 is usually whenever the object you are trying to access doesnt exists.

that's not always true. Power BI tries to find the dataset with the credentials of the calling user. If it's not found with those credentials then you might get 404 (not found) error.

 

Hi,

 

Access policies remain the same. Is this related to any limitation in the trigger, I'm triggering this once in 30 mins and i have premium capacity.

AmilaGunawardan
Frequent Visitor

Hi,

 

  1. I can confirm that Service Principle is active, and access token is generated.
  2. I have replaced the dataset, but haven't deleted the data set. Because of that, dataset ID was not changed. I have manually checked for any changes of dataset ID.

I will include the Resolve-PowerBIError output below for easier debugging

 

Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 29


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (403) Forbidden.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (403) Forbidden.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (403) Forbidden.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (403) Forbidden.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     : {"Message":"API is not accessible for application"}
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (400) Bad Request.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (400) Bad Request.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (400) Bad Request.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (400) Bad Request.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (403) Forbidden.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (403) Forbidden.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     : {"Message":"API is not accessible for application"}
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 30


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 29


Exception        : System.Net.WebException: The remote server returned an error: (403) Forbidden.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (403) Forbidden.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     : {"Message":"API is not accessible for application"}
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 29


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27


Exception        : System.Net.WebException: The remote server returned an error: (404) Not Found.
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
InnerException   : False
Message          : The remote server returned an error: (404) Not Found.
StackTrace       :    at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
                      at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink         :
Source           : Microsoft.PowerShell.Commands.Utility
ErrorDetails     :
ErrorCategory    : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 27

 

This error happened because the service principle access got revoked without a warning.

NandanHegde
Super User
Super User

Can you confirm the below 2 aspects:

1) The Service principal is still active in AAD and Access token is getting generated via the SP.

2) The workspace ID and datasetid are still the same? Because in case if you delete the dataset and republish it with same name in same workspace, the datasetid is newly created

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors