3 Replies Latest reply: Mar 14, 2018 11:02 AM by Elia Dal Santo RSS

    Cross-Origin problem with NPrinting API

    Elia Dal Santo

      Hello everyone


      I'm trying to invoke the NPrinting API from a mashup website, which is located on a different domain.

      However, when I try to invoke the API, like this:

      let requestBody = {
        type: "Report",
        config: {
          reportId: reportUid,
          outputFormat: outFormat
        method: "POST",
        url: npEndpoint + '/ondemand/requests',
        data: requestBody,
        xhrFields: {
          withCredentials: true


      The browser gives the following error:

      Failed to load https://alt157vir:4993/api/v1/ondemand/requests: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:61817' is therefore not allowed access. The response had HTTP status code 502.


      The thing is, the NPrinting documentation states that:

      All endpoints also support the HTTP OPTIONS verb, and will respond with the correct CORS headers (cross-origin resource sharing) based on the Qlik NPrinting Server settings.

      (from here: https://help.qlik.com/en-US/nprinting/September2017/Content/Extending/Intro-Extending.htm)

      but I cannot find those settings! Where can I configure this?

        • Re: Cross-Origin problem with NPrinting API
          Ruggero Piccoli



          I'm not a developer so I asked the help of a colleague. If seems an authentication issue, so you should check the code

          return $.ajax( {

            method: 'POST',

            url: url,

            xhrFields: {

                withCredentials: true


            headers: headers,

            dataType: 'json',

            contentType: 'application/json; charset=utf-8',

            data: objData

          } );


          Here there is an example in Python NPrinting API script Example - Python different language but you can see how to connect.



          Best Regards,



          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 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.

          • Re: Cross-Origin problem with NPrinting API
            Elia Dal Santo

            Well, I found out the problem.

            You have to add the origin domain to the "trusted QlikView server" in NPrinting web console -> admin -> settings -> on-demand settings.


            I didn't try that at first because I thought it was a specific setting for QlikView (as the name implies), when in reality it lets you add trusted origins of any kind. They should really change the name of that setting, it's confusing imho.