Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm finding hard to find information on the QlikNprinting-CLI. I have been using the "QlikNprinting-CLI" to dump the report Templates. Problem is after dumping the first few report templates I'm getting an error message. "The remote server returned an error: (500) Internal Server Error." I need to figure out how to get the "Invoke-NPRequest" command to skip over the errors. I have tried to set the -erroraction switch and -warningaction switches to get it to skip over the errors. But these are not working. I have inclused a sample of the code below.
$Reports = Invoke-NPRequest -method Post -Path reports/filter -NPE -Data $FilterOBJ
foreach($Report in $Reports.list){
$Report
$ExportFile = "$($ExportDIR)\$($Report.title).zip"
$errorvar = ""
#Call the export API. (this requires QlikNPrinting-CLI 1.0.0.10 or above)
$ExportAction = ""
Try {
$ExportAction = Invoke-NPRequest -NPE -Path "reports/$($Report.id)/export" -method Post -Data $ExportObj -OutFile $ExportFile -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -WarningVariable warningvar -ErrorVariable errorvar
} Catch {
Write-Error "Something Bad happened"
}
$ExportAction = Invoke-NPRequest -NPE -Path "reports/$($Report.id)/export" -method Post -Data $ExportObj -OutFile $ExportFile -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -WarningVariable warningvar -ErrorVariable errorvar
if($warningvar.length -gt 0) {Write-Output "Warning: $($warningvar)"}
if($errorvar.length -gt 0) {Write-Output "Error: $($errorvar)"}
}
Hi Michasiuk,
As the QlikNPrinting-CLI is OpenSource project, not a Qlik Product, it may be better to use the GitHub Issues page for reporting these types of problems.
At a quick look, it appears that Line 334 $EXCEPTION should be Write-Error $EXCEPTION and Line 336 should be a Return not a break. Modifying those two lines in the psm1 should resolve it.
It's working now thanks for your help.
Hi Michasiuk,
As the QlikNPrinting-CLI is OpenSource project, not a Qlik Product, it may be better to use the GitHub Issues page for reporting these types of problems.
At a quick look, it appears that Line 334 $EXCEPTION should be Write-Error $EXCEPTION and Line 336 should be a Return not a break. Modifying those two lines in the psm1 should resolve it.
How do we modify that and what do we modify it to? @Marc
Sorry Mis read your comment will try your suggestion and will report the result
It's working now thanks for your help.