This is an example for how to execute an API call "get /ondemand/requests/{requestId}/result" for the NPrinting On-Demand API as described in here:
https://help.qlik.com/en-US/nprinting/February2020/APIs/NP+API/index.html?page=36Preconditions for the API call:
- The API call was executed in Windows PowerShell ISE
- A JWT token was created in here:
https://jwt.io/- A first API call "post /ondemand/requests" was executed in order to generate a request ID which was used in the call "get /ondemand/requests/{requestId}/result"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$hdrs = @{}
$body = '{}'
$hdrs.Add("Authorization","Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidX...9qTTUWGDhUxNBYHK7MCveUStkY_JfRyw7HHJNglJNjCCLH-mNvA")
$url = "https://qlikserver1.domain.local:4993/api/v1/ondemand/requests/f2d845de-8464-45ef-8275-31919a84b2c7/result"
Invoke-RestMethod -Uri $url -Method Get -ContentType 'application/json' -Headers $hdrs | ConvertTo-Json -Depth 10