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: 
mredeker
Contributor
Contributor

NPrinting REST API and OnDemandRequestFilters

All,

I am using the NPrinting REST API to trigger OnDemandReport generation with subsequent download of the generated report file into my Java application. So far all works fine

Since we have a multi tenant application each tenant is supposed to only see his data. For this I created a global filter and attached that to the NPrinting report. Using the API I can change the filter field value and the report is created correct for the appropriate tenant

I was wondering if this is a thread safe solution? What if 2 tenants request the same report at the same time and my code is changing the global filter. Is the last one the winner and both clients would receive the report with the same data?

So I was thinking that I don't attach the filter directly to the report but use the OnDemandRequestFilters when triggering the OnDemandReportRequest. Unfortunately I don't find any documentation about this. The API reference only states that there is an object called OnDemandRequestFilters but with no further information.What is the documented "initialBookmark" supposed to be? Is that a filter Id? Do you have any code samples for the REST API and how to use the OnDemandRequestFilters?

Thanks,

-Marcus

8 Replies
Ruggero_Piccoli
Support
Support

Hi,

Each single request is isolated so each will be processed with its filters. This answer is based on the way of work of Qlik NPrinting. Qlik NPrinting can manage multiple requests at the same time, the Scheduler coordinates the work among Engines.

So In my opinion you don't risk to have two requests with different filters that come back with the same data.

I'm sorry but I don't have code samples on this topic more than what you can see in the help site.

Best Regards,

Ruggero

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT https://community.qlik.com/docs/DOC-14806. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
mredeker
Contributor
Contributor
Author

Since I only have one filter and I am using the REST API to change this filters field value, it could be that my 2 threads each change the value and then I call the REST API for the OnDemandReportRequest. In this case both report generations use the filter field value from the last change.

I was able to stop my to threads right before I call the OnDemandRequest and was able to verify that both reports are identical. This would be a show stopper for this scenario Of course I could synchronize the calls to the REST API which would be not so nice.

So I need to create a new filter for each request and attach it to the OnDemandRequest which brings me back to my second part of the question, how are OnDemandRequestFilters used??

Regards,

-Marcus

T0mm450-3rc0l3
Employee
Employee

You will have a problem trying to modify the filter and requesting two reports at the same time. You are right, it is not thread safe.

You have many solution:

Use JWT to authenticate your user and have Section Access or User filters in place.

Use OnDemandRequestFilters AdditionalFilters to specify the GUID of the Filters to apply  (so in theory you can have one filter per tenant and use its ID to identify the filter).

mredeker
Contributor
Contributor
Author

Thanks, Tommaso, for the confirmation

It sounds like you used the OnDemandRequestFilters JSON object already.

Do you have any code snippet for me?

Regards,

-Marcus

tauceef
Partner - Contributor III
Partner - Contributor III

Hi All,

Has anyone used OnDemandRequestFilters JSON object? I tried multiple ways:

  1. {\"filters\": { \"additionalFilters\" : [ { \"ColumnName: value\" } ] } }
  2. {\"filters\" : { \"additionalFilters\" : [ { \"ColumnName\": \"value\" } ] } }    with this syntax request is getting failed.
  3. {\"filters\" : { \"additionalFilters\" : [ {\"Nprinting filter ID\" } ] } }       filter ID like "xxxxxxxx-a922-4135-aaad-xxxxxxxx"

but nothing works. looking forward for help from the experts.

Additional Info: we are trying to implement on-demand report generation from mashup portal in .net code. I am able to create the session and on-demand request, report is also getting generated (downloading all data) but we are stuck at passing filter value(s). I tried to pass the filter value selected in mashup using "selections" property but that didn't worked after that trying to use "filters" that is also not working.

Please let me know if any more details required.

Regards,

Tauceef

 

Ruggero_Piccoli
Support
Support



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
fabdulazeez
Partner - Creator III
Partner - Creator III

Hi Ter,

Is it possible to use JWT authentication to use on demand reporting API

Ruggero_Piccoli
Support
Support

Hi @fabdulazeez ,

Please avoid to comment 3 years old posts like this because things could be changed in a so long time, and, please, also be on topic. I suggest you to open a new conversation with a meaningful subject and invest all the needed time to explain your question. This will help other readers to help you.

About On-Demand refer to https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/On-Demand/Intro-On-Demand.htm. JWT authentication is mentioned but we don't know if you want to use On-Demand for Qlik Sense or QlikView.

About API refer to https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/Extending/Intro-Extending.htm. Requirements for authentication is mentioned there.

Best Regards,

Ruggero

 



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.