File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,17 @@ function Invoke-SlackAPI {
31
31
$uri = $uriRequest.ToString ()
32
32
}
33
33
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
+ }
35
45
$response = $response.Content | ConvertFrom-Json
36
46
if ($response.ok ) {
37
47
$response
Original file line number Diff line number Diff line change 1
1
2
2
@ {
3
3
RootModule = ' Slack.Backup.psm1'
4
- ModuleVersion = ' 1.1.1 '
4
+ ModuleVersion = ' 1.1.3 '
5
5
GUID = ' 5fca212b-de20-40cb-ba38-e6114263bfaa'
6
6
Author = ' Alan Plocieniak'
7
7
CompanyName = ' Alan Plocieniak'
You can’t perform that action at this time.
0 commit comments