Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Mar 10, 2023 6:49:07 AM
Mar 10, 2023 6:49:07 AM
A DoS (Denial of Service) protection may trigger Error 429 while generating repetitive calls to the QRS API.
See Qlik Sense QRS API: Error 429 in September 2020 and later when uploading a file for details.
The following PowerShell demonstrates how to use the API /qrs/selection to run an action (such as delete) on multiple items of a Qlik Management Console resource (example: App) while preventing the HTTP 429 error triggered by sending too many requests.
The same approach prevents the engine stall if the DoS (Denial of Service) protection is disabled as shown on the article Qlik Sense QRS API: Error 429 in September 2020 and later when uploading a file.
Here is a PowerShell sample that provides a command line interface for showing how to automatically delete all the Apps of a Stream in a safe way:
$ServerName = "apcqscn01.apc.pri"
$StreamName = "TestDeleteApp"
$AppsToDelete = Get-QlikApp -filter "stream.id eq $($Stream.id)"
$NAppsToDelete = $AppsToDelete.count
$Count = 1
Write-Host "Deleting $($NAppsToDelete) Apps from Stream $StreamNames "
$Selections = @()
foreach($AppToDelete in $AppsToDelete)
{
#$AppToDelete = $App.id
$Selections += [pscustomobject] @{
type = 'App'
objectID = $AppToDelete.id
}
#Write-Host "Deleted App '$($AppToDelete.name)' - $Count of App $NAppsToDelete "
$Count +=1
}
$SelectionsRequest = @{
items = $Selections
}
$Body = ConvertTo-Json $SelectionsRequest -depth 10 -Compress
$Url = $("https://" + $ServerName + "/qrs/Selection")
$SelectionAnswer = Invoke-QlikPost -path /qrs/Selection -body $Body #-Verbose
$Path = $("/qrs/selection/" + $SelectionAnswer.id +"/app")
Measure-Command { $DeleteRresult = Invoke-QlikDelete -path $Path #-Verbose
}
The script has been successfully tested to delete 300 App in a call on a small test environment.
#Qlik Sense Enterprise on Windows September 2020 and later releases