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

Qliksense Rest API Script to NPrinting Broken After updating Both Nprinting and Qliksense

Hi All

I recently updated Qliksense to Feb 2020 Patch 1 and NPrinting to Feb 2020 SR1. I redistributed the certificates and all is working well (Nprinting talking to sense all fine)

The only issue I have now is with a script I use in sense that uses rest connectors to publish tasks on NPrinting.

When testing the Rest Connectors they work fine. it seems the vCookie varible ends up blank and all subsequent calls fail with a 403 error.

After the below script runs the vCookie variable ends up empty although the vCookieRaw varible contains a bunch of text.

I'm guessing something has changed in the new versions and I am no longer able to get the Cookie data? Can anybody assist?

 

LIB CONNECT TO $(vAPIConnectionNameForGET);


let vEndpoint= vNPrintingServer & '/api/v1/login/ntlm' ;

RestConnectorMasterTable:
SQL SELECT
"Content-Length",
"Cache-Control",
"Content-Type",
"Date",
"Set-Cookie",
"Server",
"__KEY__response_header",
(SELECT
"result",
"code",
"message",
"__FK_root"
FROM (wrap on) "root" FK "__FK_root")
FROM JSON "_response_header" PK "__KEY__response_header"
with Connection (URL "$(vEndpoint)");

[_response_header]:
LOAD
[Set-Cookie] AS [Set-Cookie]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);


//Set Cookie header

let vCookieRaw = peek( 'Set-Cookie',0,'_response_header');

if vSSL='No' then
let vCookie=TextBetween('$(vCookieRaw)','HttpOnly,','Path=/',1);
else
let vCookie = TextBetween('$(vCookieRaw)','Secure;','Path=/',2);
end if


//Remove login tables
DROP TABLES RestConnectorMasterTable,[_response_header];
//exit script;

Labels (2)
1 Solution

Accepted Solutions
craig_brett
Contributor II
Contributor II
Author

Adjusted the line below from

let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);

to

let vCookie = TextBetween('$(vCookieRaw)','Secure; SameSite=None,','Path=/',2);

 

And its working... Wasted half a day on this... Nothing in the Upgrade notes explaining how this has been broken...

 

View solution in original post

9 Replies
craig_brett
Contributor II
Contributor II
Author

Adjusted the line below from

let vCookie = TextBetween('$(vCookieRaw)','Secure,','Path=/',2);

to

let vCookie = TextBetween('$(vCookieRaw)','Secure; SameSite=None,','Path=/',2);

 

And its working... Wasted half a day on this... Nothing in the Upgrade notes explaining how this has been broken...

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

It is not like it has not been mentioned in release notes...

2.png

 

you should have searched for it before wasting half a day.

1.png

It is actually mentioned in release notes that there is a change in cookie. The fact that we use text search in our scripts has nothing to do with the actual API response change and functionality.

I posted it here: https://community.qlik.com/t5/Qlik-NPrinting-Documents/NPrinting-February-2020-Change-required-to-sc...

and here: https://nprintingadventures.com/2020/03/27/nprinting-api-qlik-rest-subroutines-v1-2/

and I answered 2 other questions regarding this just few days ago:

https://community.qlik.com/t5/Qlik-NPrinting-Discussions/NPrinting-Task-Execution-call-using-Rest-AP...

and here

https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Starting-tasks-in-nprinting-from-Qlik-Sense...

 

lesson learned:

check before wasting half a day and check before posting duplicate entry on community.

 

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.
craig_brett
Contributor II
Contributor II
Author

Thank you for the valuable life lesson. I did read the release notes but didn't realize that the note regarding google chrome cookies was applicable.

I'm also not sure what you mean by duplicate posts? I posted a question then managed to answer my own question before anyone had replied so I posted my answer as a reply for anyone else who may find this post by using the search feature (Unlike me)

At least now anyone who finds this post can also benefit from your wisdom.

In summary, please everybody, don't post a question until every last option has been explored. You might end up wasting your own or somebody else's precious time, thanks again Lech.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi ,

what I meant by "duplicate post" is the fact that before you post your question you are encouraged by the community form to check if similar questions were already answered. This is to prevent from churning the same already answered questions again and again. If you look at the screenshot you will see that this process would already lead you to the answer you were searching for half of your day.

1.png 

I am spending on community time every day answering the same questions over and over again, so I can easily say who is posting a question without looking for an answer and who has exhausted and checked at least top 3 topics from community search and qlik help site before posting a question. 

Lets be honest - have you use the community search before posting your question? If you did I am surprised you did not find the correct answer straight away. If you didn't, then you are right, valuable lesson learned. 

I am not trying to discourage people from posting questions, I am trying to help the find answers faster.

cheers

Lech

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.
craig_brett
Contributor II
Contributor II
Author

True, I may not have exhausted all options on this site as I rarely post or browse these forums and they are unfamiliar to me. (Member since 2018 and 2 posts to my name)

The check title feature is handy and I'll be sure to use it should I pluck up the courage to post any other questions in this friendly community, so thanks for that.

Normally a simple google search leads me to my answers. In this case google failed me as well as a hasty search on here so I thought why not make a post. We now have a post with a nicely searchable subject and a simple answer that will hopefully assist others.

Sorry to have wasted your time.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Craig,

no need to be sorry - my comments meant to help you/others find answers... I find sometimes that when using my english I may sound little bit harsh or sarcastic, but don't get me wrong I am here to help. 

If next time you find a courage to post next question regarding NPrinting i bet you I will be checking if the answer was already answered 🙂

btw: hats of to you that you have done google search, not many people do that. In this case i guess sisnce it was quite new content  google search was not indexed yet hence did not come up at the top. 

cheers

Lech

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.
Nags
Partner - Contributor III
Partner - Contributor III

@Lech_Miszkiewicz 

Is there any Nprinting cookie change in June 2020 release? I gone through the release notes and the link you have provided above but do not see anything related to cookie changes.

I'm using the below code but getting error - 403:

let vCookie = TextBetween('$(vCookieRaw)','Secure; SameSite=None,','Path=/',2);

Appreciate your help!

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Have you upgraded Qlik Sense to June? If you did then there is a bigger issue - RestConnector is causing problem.

more on that here:

https://community.qlik.com/t5/Qlik-NPrinting-Discussions/Nprinting-REST-API-broke-after-June-2020-up...

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.
Nags
Partner - Contributor III
Partner - Contributor III

@Lech_Miszkiewicz 

Thank you for the response on this topic. Yes I looked into the link that you have shared, changed 

from

//Extracts session cookie from the API response
Let vCookieRaw  = Peek('Set-Cookie',0,'cookie_items');
Let vCookie     = TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',2);

to

//Extracts session cookie from the API response
Let vCookieRaw  = Peek('Set-Cookie',0,'cookie_items');
Let vCookie     = TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',3);

and now it is working fine.

No, we haven't upgraded to June 2020 Qlik Sense. We have to wait on that before this REST API issue resolved there.