<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Run a Qlik NPrinting API POST command via QlikView reload script in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Run-a-Qlik-NPrinting-API-POST-command-via-QlikView-reload-script/ta-p/1822137</link>
    <description>&lt;P&gt;This tutorial contains an example of how to run a Qlik NPrinting API call with POST method from a QlikView script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Environment:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;LI-PRODUCT title="Qlik NPrinting" id="qlikNPrinting"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are interested in running Qlik NPrinting API calls from a Qlik Sense script refer to&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Qlik-NPrinting-Discussions/How-to-use-Qlik-NPrinting-APIs-inside-a-Qlik-Sense-load-script/m-p/54445" target="_blank" rel="noopener"&gt;How to use Qlik NPrinting APIs inside a Qlik Sense load script&lt;/A&gt;. The Qlik REST connector is the same for both QlikView and Qlik Sense so there are small differences in using it in the two environments.&lt;/P&gt;
&lt;P&gt;The Qlik REST Connector need to be installed in QlikView. You can refer to the official instruction at&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/REST-connector.htm" target="_blank" rel="noopener"&gt;REST Connector&lt;/A&gt;.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a trusted origin in Qlik NPrinting with the name of the computer where you will run the QlikView script:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_0-1626268249132.png" style="width: 1744px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58575i62DA59B1453C0D53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_0-1626268249132.png" alt="Ruggero_Piccoli_0-1626268249132.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;We will run a connection cache reload, so retrieve its ID by opening it in the browser and copying the last part of the URL.&lt;/LI&gt;
&lt;LI&gt;Create a new QlikView Document, open the load script editor and create a new REST connection:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_1-1626269067494.png" style="width: 562px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58577i0ABA6E5F40B36A90/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_1-1626269067494.png" alt="Ruggero_Piccoli_1-1626269067494.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Start to fill the connection form:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_2-1626271015448.png" style="width: 586px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58580i8BD2FB379C83663D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_2-1626271015448.png" alt="Ruggero_Piccoli_2-1626271015448.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI&gt;Insert the NTLM authentication URL&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/nprinting/May2021/APIs/NP+API/index.html?page=14" target="_blank" rel="noopener"&gt;post /login/ntlm&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Set the method to POST&lt;/LI&gt;
&lt;LI&gt;Select Windows NTLM as Authentication Schema&lt;/LI&gt;
&lt;LI&gt;Insert Username and Password&lt;/LI&gt;
&lt;LI&gt;Flag the Skip server certificate validation option if your Qlik NPrinting server has not a valid SSL certificate&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_1-1626272240559.png" style="width: 586px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58583i17BA9AB1B1DB3E9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_1-1626272240559.png" alt="Ruggero_Piccoli_1-1626272240559.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Scroll down and in the Query headers insert origin as name and the URL of the trusted origin you set few steps ago in the Qlik NPrinting Server.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Check the flag Allow repornse headers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Click on Test Connection, if it works correctly click on ok. The connection string will be inserted in the QlikVew script.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;Insert the code to retrieve the connection cookie:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;LI-CODE lang="markup"&gt;let vNPrintingServer = 'https://YourServerAddress:4993';

RestConnectorMasterTable:
SQL SELECT 
	"Set-Cookie",
	"__KEY__response_header"
FROM JSON "_response_header" PK "__KEY__response_header";

[_response_header]:
LOAD[Set-Cookie] AS [Set-Cookie]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);

Let vCookieRaw  = Peek('Set-Cookie',0,'cookie_items');

Let vCookie = TextBetween(vCookieRaw,'SameSite=None,',' Path=/',SubStringCount(vCookieRaw,'SameSite=None')-1);

DROP TABLE RestConnectorMasterTable;&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Insert the code to run the POST call to run the cache reload&amp;nbsp;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://help.qlik.com/en-US/nprinting/May2021/APIs/NP+API/index.html?page=22" target="_blank" rel="noopener"&gt;post /connections/{&lt;/A&gt;&lt;BR /&gt;&lt;LI-CODE lang="markup"&gt;let vReloadMetadataURL=  vNPrintingServer  &amp;amp; '/api/v1/connections/YourConnectionID/reload';

RestNPReloadMetadataTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vReloadMetadataURL)", HTTPHEADER "cookie" "$(vCookie)");

[metadata_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPReloadMetadataTable
WHERE NOT IsNull([__KEY_data]);

DROP TABLE RestNPReloadMetadataTable;​&lt;/LI-CODE&gt;&lt;BR /&gt;For detailed explanations of the script, refer to the official REST Connector documentation.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Run the reload script. Open the Task Executions page of your Qlik NPrinting server. If everything went good you will see the reload cache running.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_2-1626272450971.png" style="width: 1733px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58584i5A05ADD71E1B8C4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_2-1626272450971.png" alt="Ruggero_Piccoli_2-1626272450971.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2022 11:54:07 GMT</pubDate>
    <dc:creator>Ruggero_Piccoli</dc:creator>
    <dc:date>2022-04-19T11:54:07Z</dc:date>
    <item>
      <title>Run a Qlik NPrinting API POST command via QlikView reload script</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Run-a-Qlik-NPrinting-API-POST-command-via-QlikView-reload-script/ta-p/1822137</link>
      <description>&lt;P&gt;This tutorial contains an example of how to run a Qlik NPrinting API call with POST method from a QlikView script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Environment:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;&lt;LI-PRODUCT title="Qlik NPrinting" id="qlikNPrinting"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are interested in running Qlik NPrinting API calls from a Qlik Sense script refer to&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Qlik-NPrinting-Discussions/How-to-use-Qlik-NPrinting-APIs-inside-a-Qlik-Sense-load-script/m-p/54445" target="_blank" rel="noopener"&gt;How to use Qlik NPrinting APIs inside a Qlik Sense load script&lt;/A&gt;. The Qlik REST connector is the same for both QlikView and Qlik Sense so there are small differences in using it in the two environments.&lt;/P&gt;
&lt;P&gt;The Qlik REST Connector need to be installed in QlikView. You can refer to the official instruction at&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/REST-connector.htm" target="_blank" rel="noopener"&gt;REST Connector&lt;/A&gt;.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a trusted origin in Qlik NPrinting with the name of the computer where you will run the QlikView script:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_0-1626268249132.png" style="width: 1744px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58575i62DA59B1453C0D53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_0-1626268249132.png" alt="Ruggero_Piccoli_0-1626268249132.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;We will run a connection cache reload, so retrieve its ID by opening it in the browser and copying the last part of the URL.&lt;/LI&gt;
&lt;LI&gt;Create a new QlikView Document, open the load script editor and create a new REST connection:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_1-1626269067494.png" style="width: 562px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58577i0ABA6E5F40B36A90/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_1-1626269067494.png" alt="Ruggero_Piccoli_1-1626269067494.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Start to fill the connection form:&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_2-1626271015448.png" style="width: 586px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58580i8BD2FB379C83663D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_2-1626271015448.png" alt="Ruggero_Piccoli_2-1626271015448.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI&gt;Insert the NTLM authentication URL&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/nprinting/May2021/APIs/NP+API/index.html?page=14" target="_blank" rel="noopener"&gt;post /login/ntlm&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Set the method to POST&lt;/LI&gt;
&lt;LI&gt;Select Windows NTLM as Authentication Schema&lt;/LI&gt;
&lt;LI&gt;Insert Username and Password&lt;/LI&gt;
&lt;LI&gt;Flag the Skip server certificate validation option if your Qlik NPrinting server has not a valid SSL certificate&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_1-1626272240559.png" style="width: 586px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58583i17BA9AB1B1DB3E9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_1-1626272240559.png" alt="Ruggero_Piccoli_1-1626272240559.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Scroll down and in the Query headers insert origin as name and the URL of the trusted origin you set few steps ago in the Qlik NPrinting Server.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Check the flag Allow repornse headers.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Click on Test Connection, if it works correctly click on ok. The connection string will be inserted in the QlikVew script.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;&lt;SPAN&gt;Insert the code to retrieve the connection cookie:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;LI-CODE lang="markup"&gt;let vNPrintingServer = 'https://YourServerAddress:4993';

RestConnectorMasterTable:
SQL SELECT 
	"Set-Cookie",
	"__KEY__response_header"
FROM JSON "_response_header" PK "__KEY__response_header";

[_response_header]:
LOAD[Set-Cookie] AS [Set-Cookie]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);

Let vCookieRaw  = Peek('Set-Cookie',0,'cookie_items');

Let vCookie = TextBetween(vCookieRaw,'SameSite=None,',' Path=/',SubStringCount(vCookieRaw,'SameSite=None')-1);

DROP TABLE RestConnectorMasterTable;&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;Insert the code to run the POST call to run the cache reload&amp;nbsp;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://help.qlik.com/en-US/nprinting/May2021/APIs/NP+API/index.html?page=22" target="_blank" rel="noopener"&gt;post /connections/{&lt;/A&gt;&lt;BR /&gt;&lt;LI-CODE lang="markup"&gt;let vReloadMetadataURL=  vNPrintingServer  &amp;amp; '/api/v1/connections/YourConnectionID/reload';

RestNPReloadMetadataTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vReloadMetadataURL)", HTTPHEADER "cookie" "$(vCookie)");

[metadata_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPReloadMetadataTable
WHERE NOT IsNull([__KEY_data]);

DROP TABLE RestNPReloadMetadataTable;​&lt;/LI-CODE&gt;&lt;BR /&gt;For detailed explanations of the script, refer to the official REST Connector documentation.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Run the reload script. Open the Task Executions page of your Qlik NPrinting server. If everything went good you will see the reload cache running.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruggero_Piccoli_2-1626272450971.png" style="width: 1733px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/58584i5A05ADD71E1B8C4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ruggero_Piccoli_2-1626272450971.png" alt="Ruggero_Piccoli_2-1626272450971.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 11:54:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Run-a-Qlik-NPrinting-API-POST-command-via-QlikView-reload-script/ta-p/1822137</guid>
      <dc:creator>Ruggero_Piccoli</dc:creator>
      <dc:date>2022-04-19T11:54:07Z</dc:date>
    </item>
  </channel>
</rss>

