File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,17 @@ function Invoke-SlackAPI {
3131 $uri = $uriRequest.ToString ()
3232 }
3333
34- $response = Invoke-WebRequest - Method Get - Uri $uri - Headers $headers
34+ try {
35+ $response = Invoke-WebRequest - Method Get - Uri $uri - Headers $headers
36+ }
37+ catch [Microsoft.PowerShell.Commands.HttpResponseException ] {
38+ if ($_.Exception.Response.StatusCode -eq 429 ) {
39+ [int ] $delay = [int ](($_.Exception.Response.Headers | Where-Object Key -eq ' Retry-After' ).Value[0 ])
40+ Write-Host - Message " Retry caught, delaying $delay s"
41+ Start-Sleep - Seconds $delay
42+ return Invoke-SlackAPI $Method $Token $Parameters
43+ }
44+ }
3545 $response = $response.Content | ConvertFrom-Json
3646 if ($response.ok ) {
3747 $response
Original file line number Diff line number Diff line change 11
22@ {
33 RootModule = ' Slack.Backup.psm1'
4- ModuleVersion = ' 1.1.1 '
4+ ModuleVersion = ' 1.1.3 '
55 GUID = ' 5fca212b-de20-40cb-ba38-e6114263bfaa'
66 Author = ' Alan Plocieniak'
77 CompanyName = ' Alan Plocieniak'
You can’t perform that action at this time.
0 commit comments