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: 
sturmeyp
Contributor II
Contributor II

NPrinting API newbie question

HI All

Would like to start using the NPrinting API - in my case I would be calling it from PowerShell scripts

I've read lots of stuff on the net and Qlik forums and have got so far but now a little stuck
In the example below I'm wanting to run an NPrinting task based on the ID

The first section I authenticate and get cookie, then I Extract XSRF token from cookie, I then try to execute the NPrinting task.

# Authenticate and get cookie
$url = "https://nprinting.corp.ourdomain.com:4993/api/v1/login/ntlm"
Invoke-RestMethod -UseDefaultCredentials -Uri $url -Method Get -Headers $hdrs -SessionVariable websession
$cookies = $websession.Cookies.GetCookies($url)
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$session.Cookies.Add($cookies);

# Extract XSRF token from cookie
$xsrf_token = $($cookies | Where-Object {$_.Name -eq "NPWEBCONSOLE_XSRF-TOKEN"}).Value

# Execute NPrinting task
$taskid = 'abd2531c-60e3-4057-917a-b1dd3730c1ed'
$url = "https://nprinting.corp.ourdomain.com:4993/api/v1/tasks/$($taskid)/executions"
Invoke-RestMethod -WebSession $session -Uri $url -Method Post -Headers $hdrs

I'm getting a "403 message stating user has no rights"

Invoke-RestMethod : {"code":403,"message":"User has no rights to access the resource"}
At line:14 char:1
+ Invoke-RestMethod -WebSession $session -Uri $url -Method Post -Header ...

My user account has admin role on NPrinting so not sure what else to check?
We are running NPrinting May 2022 SR4 and Qlik Sense Enterprise Feb 2022

Any ideas or suggestions appreciated

Paul

Labels (3)
1 Solution

Accepted Solutions
Frank_S
Support
Support

Hi @sturmeyp

Check that you have added your 'origin qlik sense or qlikview server' to the trusted origins setting on the NP web console under Admin>Settings>On Demand/Add Trusted Origin

Check this and other points mentioned here:

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

2 Replies
Frank_S
Support
Support

Hi @sturmeyp

Check that you have added your 'origin qlik sense or qlikview server' to the trusted origins setting on the NP web console under Admin>Settings>On Demand/Add Trusted Origin

Check this and other points mentioned here:

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

to follow up on Franks idea - the origin will be the machine you are trying to run your api call from

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.