Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Highlighted
nsm1234567
Contributor

Run "Import" QRS request using Qliksense Rest Connector (Post Request)

Hi there,

I'm currently looking to automate a process where apps are moved from our production server to a QA server.  Everything was running fine until I attempted to import the app on the QA server.  I have the below powershell script that I wrote which works 100% and imports and app to the server, but attempting to do the same thing with the Qliksense Rest connector doesn't work (I'd prefer to have this run in Qliksense so it can be managed by other developers).  Below I've pasted screenshots of my setup.  Can Qliksense not do this kind of connect?  It gives me an error saying "403 (No client certificate supplied)"

Working powershell script:

param([string]$tempcontent,[string]$appname)

$hdrs = @{}
$hdrs.Add("X-Qlik-Xrfkey","0123456789abcdef")
$hdrs.Add("X-Qlik-User", "UserDirectory=internal; UserId=sa_repository")

$CertPath = "C:\ProgramData\Qlik\Sense\Engine\Certificates\client.pfx"
$CertPass = "something"
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertPath, $CertPass)

$body = @{
    "name" = "simple_test.qvf"
    "ContentType" = "application/json; charset=utf-8"

} | ConvertTo-Json

$body

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

Invoke-RestMethod -Uri "https://server:4242/qrs/app/import?xrfkey=0123456789abcdef&name=test_import" -Method Post -Headers $hdrs -Body {"simple_test.qvf"} -ContentType 'application/json'  -Certificate $cert

Not working Rest connect from Qliksense:

3.png2.png1.png

 

 

 

 

Labels (3)