Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
michasiuk
Contributor III
Contributor III

QlikNprinting-CLI: Invoke-NPRequest "SilentlyContinue" not working properly

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)"}
}

 

@Marc

 

 

Labels (1)
2 Solutions

Accepted Solutions
Marc
Employee
Employee

 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.

 

View solution in original post

michasiuk
Contributor III
Contributor III
Author

It's working now thanks for your help.

View solution in original post

4 Replies
Marc
Employee
Employee

 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.

 

michasiuk
Contributor III
Contributor III
Author

How do we modify that and what do we modify it to? @Marc 

michasiuk
Contributor III
Contributor III
Author

Sorry Mis read your comment will try your suggestion and will report the result

michasiuk
Contributor III
Contributor III
Author

It's working now thanks for your help.