Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
We have recently migrated to NPrinting February 2020 SR1 version. Everything went smoothly and the server was up and running in no time. The only problem we are struggling to fix is the REST API calls to execute tasks.
API call to login URL is working i.e. https://nprinting_server/api/v1/login/ntlm
But all the other calls to URLs like the following giving me error "QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 403 (Forbidden)."
https://nprinting_server/api/v1/users or
https://nprinting_server/api/v1/tasks/430133d4-7ce7-4418-96f2-ef4112339d4b/executions
Script code that I am using is as below:
Please note that vCookie requires a little change after upgrade i.e. replace comma(,) with a semicolon(;) after the word Secure
let vCookie = TextBetween('$(vCookieRaw)','Secure;','Path=/',2);
let vPublshTaskURL = 'https://nprinting_server/api/v1/tasks/430133d4-7ce7-4418-96f2-ef4112339d4b/executions';
RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");
[_post_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPTaskTriggerTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPTaskTriggerTable;
Server throwing error:
QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 403 (Forbidden):
The server refused to fulfill the request.
I have checked the roles for user I am using to create the REST connection, which a domain user and has the Administrator role, everything looks alright.
Is there any configuration I need to make on Nprinting server to allow resources to be used from other servers?
Any suggestions to resolve the issue?
Thanks,
JM
I guess you are not inspecting/ tracing on each step what your script is doing.
I faced the same issue after upgrade however code i am using is tracing all variables i capture on the way. I noticed that cookie was not returned as the structure of the string after authentication has changed!
You need to adjust your code to capture cookie - see red bit of the code below.
You can also see Trace statements below which straight away helped me identify this issue!
I guess you are not inspecting/ tracing on each step what your script is doing.
I faced the same issue after upgrade however code i am using is tracing all variables i capture on the way. I noticed that cookie was not returned as the structure of the string after authentication has changed!
You need to adjust your code to capture cookie - see red bit of the code below.
You can also see Trace statements below which straight away helped me identify this issue!
Hi,
I did trace the variables and outputs but didn't get the idea of removing the SameSite=None from the Cookie id as the API documentation are not updated.
Our code was working fine with the earlier version of NPrinting i.e Sept 2018.
Appreciate your support and help.
Thanks,
JM
Hi,
I am glad I could help.
I was also blindsided, but then I went to Qlik download page and checked documentation. This change was highlighted in release notes as a change to cookie.
If you preview cookies in your web browser you would notice which bits are necessary.
cheers
Lech,
I tried your solution, but it's not working for me - I'm getting a protocol error 500 now.
Here's my two variables (I changed the variable names slightly):
let vNPCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vNPCookie = TextBetween('$(vNPCookieRaw)','SameSite=None,','Path=/',2);
Here's the resulting text (from a trace):
vNPCookie = 'NPWEBCONSOLE_SESSION=ac61db90490f70b1da9ae39b3c7f3d5ae4a0c6b7-%00NPWEBCONSOLE_XSRF-TOKEN%3AALEfIIvxiMe82JtSi3AUoe0ZU5dDKIjhP%2BLvCBr2qBc%3D%00%00_TS%3Asession%00%00userid%3Aad3f1e18086040a39f6b094fde386016%00%00userlogin%3A2020-03-28T17%3A02%3A09.1431719Z%00; '
Any idea what I'm doing wrong?
Wow, I feel dumb. I realized that the NPrinting task I was trying to run had been disabled. Once I enabled the task, the following code worked:
let vNPCookieRaw = Peek('Set-Cookie',0,'_response_header');
let vNPCookie = TextBetween('$(vNPCookieRaw)','SameSite=None,','Path=/',2);
Hi,
Thanks for this info.
I was trying your solution but it seems something else is going wrong. As you see in my raw session cookie TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',2) won't work as 'SameSite=None,' only comes once in whole string.
Is my raw cookie wrong ?
Raw Session Cookie:
"NPWEBCONSOLE_SESSION=7803373bd0a0e6a9ab3fb6a87e2fc8933aede485-%00_TS%3Asession%00%00NPWEBCONSOLE_XSRF-TOKEN%3AVK7fJ59JPWsnmn9vJ89JoCkxGeO8V1IHh0o3eccyc1w%3D%00; Path=/; HttpOnly; Secure; SameSite=None,NPWEBCONSOLE_SESSION=5454317aee4bdce61ae0d9de0ad9399eef193fcc-%00_TS%3Asession%00%00NPWEBCONSOLE_XSRF-TOKEN%3AVK7fJ59JPWsnmn9vJ89JoCkxGeO8V1IHh0o3eccyc1w%3D%00%00userid%3A9f88adfb825a4eb19178e0dc2c4ca312%00%00userlogin%3A2020-08-07T10%3A16%3A15.1375265Z%00; Path=/; HttpOnly; Secure; SameSite=None"
Truncated Session Cookie:
"NPWEBCONSOLE_SESSION=5454317aee4bdce61ae0d9de0ad9399eef193fcc-%00_TS%3Asession%00%00NPWEBCONSOLE_XSRF-TOKEN%3AVK7fJ59JPWsnmn9vJ89JoCkxGeO8V1IHh0o3eccyc1w%3D%00%00userid%3A9f88adfb825a4eb19178e0dc2c4ca312%00%00userlogin%3A2020-08-07T10%3A16%3A15.1375265Z%00; "