7 Replies Latest reply: May 23, 2018 11:27 PM by Andrew Ferguson 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
        }
      };
      $.ajax({
        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?