<?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>topic Working with REST API to trigger reload tasks in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-REST-API-to-trigger-reload-tasks/m-p/1188306#M5949</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Qlik Community, I'm hoping to shed some light on the best way of using the REST API to connect to the Qlik Engine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the wonderful tool, &lt;A href="http://branch.qlik.com/#!/project/56f2e998f1c173fc24afe6ec"&gt;QlikSenseTask&lt;/A&gt;, it appears that it should do exactly what I want it to do, and is a nice PC-friendly way of using the API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it turns out that someone configured our proxies and virtual proxies a bit differently, and our proxy setup redirects users to a logon form rather than prioritizing AD authentication first. As a result, using QlikSenseTask (where the app assumes AD authentication first), returns an XML package containing the login page and nothing else, where the app at this point expects the current set of requests to be authenticated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I configure an alternative proxy/virtual proxy pair that uses pass through AD authentication (or indeed, any non-form authentication), that shouldn't affect anything else? Would anyone have the default settings for these that I could use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Sep 2016 06:24:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-09-20T06:24:23Z</dc:date>
    <item>
      <title>Working with REST API to trigger reload tasks</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-REST-API-to-trigger-reload-tasks/m-p/1188306#M5949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Qlik Community, I'm hoping to shed some light on the best way of using the REST API to connect to the Qlik Engine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the wonderful tool, &lt;A href="http://branch.qlik.com/#!/project/56f2e998f1c173fc24afe6ec"&gt;QlikSenseTask&lt;/A&gt;, it appears that it should do exactly what I want it to do, and is a nice PC-friendly way of using the API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it turns out that someone configured our proxies and virtual proxies a bit differently, and our proxy setup redirects users to a logon form rather than prioritizing AD authentication first. As a result, using QlikSenseTask (where the app assumes AD authentication first), returns an XML package containing the login page and nothing else, where the app at this point expects the current set of requests to be authenticated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I configure an alternative proxy/virtual proxy pair that uses pass through AD authentication (or indeed, any non-form authentication), that shouldn't affect anything else? Would anyone have the default settings for these that I could use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2016 06:24:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-REST-API-to-trigger-reload-tasks/m-p/1188306#M5949</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-20T06:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Working with REST API to trigger reload tasks</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-REST-API-to-trigger-reload-tasks/m-p/1188307#M5950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK so I couldn't get NTLM authentication working by adding another proxy/virtual proxy and logging in via those using Qlik Sense Task from &lt;A href="http://branch.qlik.com/?&amp;amp;_ga=1.260958797.1542460252.1451345796#!/project/56f2e998f1c173fc24afe6ec" title="http://branch.qlik.com/?&amp;amp;_ga=1.260958797.1542460252.1451345796#!/project/56f2e998f1c173fc24afe6ec"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;Qlik Branch&lt;/SPAN&gt;&lt;/A&gt;, but I got it working using Authentication from the Qlik Sense certificates using examples from the Qlik Help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example connecting to the API in C#:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/ProxyServiceAPI/Content/ProxyServiceAPI/ProxyServiceAPI-Example-Connect-API-Certificates.htm" title="https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/ProxyServiceAPI/Content/ProxyServiceAPI/ProxyServiceAPI-Example-Connect-API-Certificates.htm"&gt;https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/ProxyServiceAPI/Content/ProxyServiceAPI/ProxyServiceAPI-Examp…&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code showing how to start a job:&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/RepositoryServiceAPI/Content/RepositoryServiceAPI/RepositoryServiceAPI-Task-Start-By-Name.htm" title="https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/RepositoryServiceAPI/Content/RepositoryServiceAPI/RepositoryServiceAPI-Task-Start-By-Name.htm"&gt;https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/RepositoryServiceAPI/Content/RepositoryServiceAPI/RepositoryS…&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Putting these two together (alongside figuring out what Qlik Sense Task does in &lt;A href="http://branch.qlik.com/?&amp;amp;_ga=1.260958797.1542460252.1451345796#!/project/56f2e998f1c173fc24afe6ec" title="http://branch.qlik.com/?&amp;amp;_ga=1.260958797.1542460252.1451345796#!/project/56f2e998f1c173fc24afe6ec"&gt;Qlik Branch&lt;/A&gt; using POST requests), I was able to send a POST request to the API to trigger a reload task to start, using the exported Qlik certificates for Authentication instead of NTLM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prerequisites:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Exported the Qlik certificates and copy them locally as per &lt;A href="https://help.qlik.com/en-US/sense/1.1/Subsystems/ManagementConsole/Content/QMC_Resources_Certificates_Export.htm" title="https://help.qlik.com/en-US/sense/1.1/Subsystems/ManagementConsole/Content/QMC_Resources_Certificates_Export.htm"&gt;https://help.qlik.com/en-US/sense/1.1/Subsystems/ManagementConsole/Content/QMC_Resources_Certificates_Export.htm&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;I'm passing through and running as a user that has rootadmin permissions - unsure how low you could go in permissions but at least have the permission to run the task via QMC.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code as follows:&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14749323933157181" jivemacro_uid="_14749323933157181"&gt;
&lt;P&gt;public static void ConnectWithCertForTask(string strTaskName)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;//User to fill in these&lt;BR /&gt; string strCertificatePath = "&amp;lt;path to &amp;gt;\client.pfx";&lt;BR /&gt; string strUserStringForQlik = "UserDirectory=&amp;lt;user domain&amp;gt;;UserId=&amp;lt;user id&amp;gt;";&lt;BR /&gt; string strServerName = @"&lt;A href="https://caustm01qscp010.cnh1.cnhgroup.cnh.com/"&gt;&amp;lt;URL&lt;/A&gt; of Qlik Server&amp;gt;";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;// locate the client certificate and accept it as trusted&lt;BR /&gt; X509Certificate2 SenseCert = new X509Certificate2(strCertificatePath);&lt;BR /&gt; ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//Create the HTTP Request and add required headers and content in xrfkey&lt;BR /&gt; string xrfkey = "0123456789abcdef";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;///qrs/task/start/synchronous?name={name}&lt;BR /&gt; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strServerName + @":4242/qrs/task/start/synchronous?name=" + strTaskName + "&amp;amp;xrfkey=" + xrfkey);&lt;BR /&gt; &lt;BR /&gt; request.Method = "POST";&lt;BR /&gt; //request.Accept = "application/json";&lt;BR /&gt; request.Headers.Add("X-Qlik-xrfkey", xrfkey);&lt;BR /&gt; request.Headers.Add("name", strTaskName);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//required for POST&lt;BR /&gt; request.ContentType = "application/json";&lt;BR /&gt; request.ContentLength = 0;&lt;BR /&gt; request.Expect = "application/json";&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; // Add the certificate to the request and provide the user to execute as&lt;BR /&gt; request.ClientCertificates.Add(SenseCert);&lt;BR /&gt; request.Headers.Add("X-Qlik-User", strUserStringForQlik);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//Send the request&lt;BR /&gt; request.GetRequestStream();&lt;BR /&gt; HttpWebResponse response = request.GetResponse() as HttpWebResponse;&lt;BR /&gt;}&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(note that if you are running this under ASP.NET, the line of code to load the certificate should be:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Consolas;"&gt;X509Certificate2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; SenseCert = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Consolas;"&gt;new&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Consolas;"&gt;X509Certificate2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;(strCertificatePath, &lt;/SPAN&gt;&lt;SPAN style="color: #a31515; font-size: 10pt; font-family: Consolas;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #2b91af; font-size: 10pt; font-family: Consolas;"&gt;X509KeyStorageFlags&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Consolas;"&gt;.MachineKeySet);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; font-size: 10pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So calling the code with the name of the task should result in the task being executed, my task did not contain any spaces so you may have to use HTML formatting for those tasks in the URL you send to the API.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 23:29:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Working-with-REST-API-to-trigger-reload-tasks/m-p/1188307#M5950</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-09-26T23:29:59Z</dc:date>
    </item>
  </channel>
</rss>

