Forum Discussion
Randomly receiving 503, server unavailable, when retrieving activities?
We have some power shell scripts that retrieves details regarding our Power BI tenant.
The actual lines that retrieves the activity details are:-
if (!$result.continuationUri)
{
$result = Invoke-PowerBIRestMethod -Url $activityAPIUrl -method Get | ConvertFrom-Json
}
else {
$result = Invoke-PowerBIRestMethod -Url $result.continuationUri -method Get | ConvertFrom-Json
}
if ($result.activityEventEntities)
{
$audits += @($result.activityEventEntities)
}
These scripts were downloaded from Internet that have been amended for our own purposes. When I was developing the changes, I quite often received errors about the server being unavailable. I put this down to run the scripts, too much while developing them.
I deployed as a schedule task, last Tuesday. Everything was fine until this morning when I received the usual error (even though it would have only been trying to retrieve the activities in the previous 24 hours). The error is shown below, can anybody advise?
Thanks
Error on '.\Fetch - Activity.ps1' - System.AggregateException: One or more errors occurred. --->
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote server returned an error: (503)
Server Unavailable.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__35.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.ExecuteCmdlet()
at Microsoft.PowerBI.Commands.Common.PowerBICmdlet.ProcessRecord()
---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote server
returned an error: (503) Server Unavailable.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__35.MoveNext()<---
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Fetch - Run.ps1
4 Replies
- AnonymousNot applicable
Hi Dragon496,
What type of authorizations methods are you used with rest API? OAuth, token or service principal?
If you mean the service principal mode, it requires you to re-invoke the authorization step with service principal every time before the API usages when you work with powershell scripts.
Regards,
Xiaxin Sheng
- Dragon496Helper II
As far as I can see, the scripts are using the oAuth method.
It appears to fail at random. For example, the scripts are executed by a scheduled task in the morning and it has failed twice this week and succeeded twice this week. One of the failures, I had to rerun once and the other needed five attempts.
Please note, the issue is not the schedule task. Random failures are generated, when I run the script, within Windows PowerShell ISE.
Thanks
- AnonymousNot applicable
HI Dragon496,
Perhaps you can take a look at the rest API limitation if your scenario meets to these limitations, the remote server will reject or not respond with these requests which exceed to the limitations.
Power BI REST APIs push datasets limitations - Power BI | Microsoft Learn
Regards,Xiaoxin Sheng