r/GraphAPI • u/lrosa • Apr 13 '25
HTTP 503 enumerating SharePoint sites
Hi,
I have a PowerShell script that downloads periodically some data via Graph, but I am unable to get SharePoint information.
The code is
$Headers = @{'Authorization' = "Bearer $token"}$uri = 'https://graph.microsoft.com/v1.0/sites'$r = Invoke-WebRequest -Uri $uri -Headers $Headers
but the result is
Invoke-WebRequest : The remote server returned an error: (503) Server Unavailable.At line:1 char:6+ $r = Invoke-WebRequest -Uri $uri -Headers $Headers+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
The user I use to run the script has Sites.Read permission.
Any idea?
Thank you.
1
2
u/Tanddant Apr 13 '25
You're being throttled aka.ms/spo429
Consider using something like PnP PowerShell which handles the back off mechanism for you.