homotechsual / HaloAPI

PowerShell module for the Halo Service Solutions series of software products.
MIT License
47 stars 35 forks source link

[Bug]: Hitting Hosted Halo API limit for large request #31

Closed ravenadsl closed 2 months ago

ravenadsl commented 9 months ago

Contact Details

peter.barsdell@carecomputers.co.uk

What happened?

While running queries that generate a large amount of API requests its very easy to hit the rolling rolling 300 requests per 5 minute window on the Hosted version of Halo. This will generate a warning message saying the request was throttled and trigger a sleep for 5 seconds, but this is not long enough to get to the next 5 minute window so scripts will exit with a retry request 10 times unsuccessful message.

It seems to loop through the 5 second sleep a maximum of 10 times for a total of 50 seconds. It would need to be a minimum of a 30 second sleep to guarantee waiting until the next 5 minute window.

Version

1.0.1

Which operating systems have you tested on?

What PowerShell version are you running?

7.1.3

Halo Product

Halo PSA

Halo Version

v2.126.32

What command did you run?

Get-HaloAsset

What was the output of the command?

WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
WARNING: The request was throttled, waiting for 5 seconds.
Exception: C:\Program Files\WindowsPowerShell\Modules\haloapi\1.14.1\Private\New-HaloError.ps1:65
Line |
  65 |          throw $ErrorRecord.Exception.Message
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Retried request to
     | "https://INSTANCENAME.nethelpdesk.com:443/api/asset?page_size=1000&pageinate=true&page_no=1" 10 times, request unsuccessful.
homotechsual commented 2 months ago

The retry interval is now configurable and we have local batching options to allow large request sets to work.