<?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 NPrinting 17.2.1 REST API - Create OnDemand Request in Qlik NPrinting</title>
    <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223136#M13348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I'm having issues invoking the API request to en-queue a new on-demand request as per the API (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://help.qlik.com/en-US/nprinting/17.2/APIs/NP%20API/#ondemandRequestsPost" rel="nofollow" target="_blank"&gt;https://help.qlik.com/en-US/nprinting/17.2/APIs/NP%20API/#ondemandRequestsPost&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Authentication is successful and I am able to query Apps, Filters, Reports and On-Demand Requests.&amp;nbsp; However, when I invoke the API to create an On-Demand request I receive the following error from the server:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811389674068802 jive_text_macro" jivemacro_uid="_14811389674068802"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "title": "Forbidden",&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "description": "REVEL_CSRF: tokens mismatch."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This error occurs regardless of the payload being supplied.&amp;nbsp; Even supplying no payload generates the same result.&amp;nbsp; Reviewing the error description it appears to relate to a Cross-Site Request Forgery (CSRF) exception where the authentication token associated with the current login session is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using .NET Framework v4.6.1 to query the service.&amp;nbsp; The relevant code is as follows (edited for brevity):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811389777468497 jive_text_macro" jivemacro_uid="_14811389777468497"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;public class NPrintingService&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; private HttpClient Client { get; set; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public NPrintingService(string serviceUrl)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var httpClientHandler = new HttpClientHandler { UseDefaultCredentials = true };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var client = new HttpClient(httpClientHandler)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; BaseAddress = new Uri(serviceUrl)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; client.DefaultRequestHeaders.Accept.Clear();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; this.Client = client;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public async Task&amp;lt;bool&amp;gt; Authenticate()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var response = await this.Client.GetAsync("api/v1/login/ntlm");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if (response.IsSuccessStatusCode)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return await Task.FromResult(true);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return await Task.FromResult(false);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public async Task&amp;lt;string&amp;gt; CreateOnDemandRequest()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; HttpResponseMessage response = await this.Client.PostAsJsonAsync("api/v1/ondemand/requests", null);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if (response.IsSuccessStatusCode)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var content = await response.Content.ReadAsStringAsync();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return content;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; //var error = await response.Content.ReadAsStringAsync(); // NOTE: This code is used to retrieve the underlying 'REVEL_CSRF: tokens mismatch' error&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; throw new ApplicationException($"({response.StatusCode}): {response.ReasonPhrase}");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is being used in a Console application running in the context of my domain account.&amp;nbsp; This domain account has been setup in NPrinting as a user with the 'Administrator' security role.&amp;nbsp; I've also ensured that the user has been linked with my domain account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811390100589556 jive_text_macro" jivemacro_uid="_14811390100589556"&gt;
&lt;P&gt;var service = new NPrintingService(ConfigurationManager.AppSettings["ServiceUrl"]);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;var authenticate = await service.Authenticate();&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;var result = await service.CreateOnDemandRequest(); // Exception occurs here&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can confirm that the request is &lt;STRONG&gt;successfully authenticated&lt;/STRONG&gt;.&amp;nbsp; I've also run this code with Fiddler active and confirmed that the output is the same -- Authentication is successful, but creating the On-Demand request fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone been able to successfully use this API?&amp;nbsp; If so, how?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Sep 2019 18:40:54 GMT</pubDate>
    <dc:creator />
    <dc:date>2019-09-25T18:40:54Z</dc:date>
    <item>
      <title>NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223136#M13348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I'm having issues invoking the API request to en-queue a new on-demand request as per the API (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://help.qlik.com/en-US/nprinting/17.2/APIs/NP%20API/#ondemandRequestsPost" rel="nofollow" target="_blank"&gt;https://help.qlik.com/en-US/nprinting/17.2/APIs/NP%20API/#ondemandRequestsPost&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Authentication is successful and I am able to query Apps, Filters, Reports and On-Demand Requests.&amp;nbsp; However, when I invoke the API to create an On-Demand request I receive the following error from the server:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811389674068802 jive_text_macro" jivemacro_uid="_14811389674068802"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "title": "Forbidden",&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "description": "REVEL_CSRF: tokens mismatch."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This error occurs regardless of the payload being supplied.&amp;nbsp; Even supplying no payload generates the same result.&amp;nbsp; Reviewing the error description it appears to relate to a Cross-Site Request Forgery (CSRF) exception where the authentication token associated with the current login session is different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using .NET Framework v4.6.1 to query the service.&amp;nbsp; The relevant code is as follows (edited for brevity):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811389777468497 jive_text_macro" jivemacro_uid="_14811389777468497"&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;public class NPrintingService&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; private HttpClient Client { get; set; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public NPrintingService(string serviceUrl)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var httpClientHandler = new HttpClientHandler { UseDefaultCredentials = true };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var client = new HttpClient(httpClientHandler)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; BaseAddress = new Uri(serviceUrl)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; };&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; client.DefaultRequestHeaders.Accept.Clear();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; this.Client = client;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public async Task&amp;lt;bool&amp;gt; Authenticate()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var response = await this.Client.GetAsync("api/v1/login/ntlm");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if (response.IsSuccessStatusCode)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return await Task.FromResult(true);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return await Task.FromResult(false);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; public async Task&amp;lt;string&amp;gt; CreateOnDemandRequest()&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; HttpResponseMessage response = await this.Client.PostAsJsonAsync("api/v1/ondemand/requests", null);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; if (response.IsSuccessStatusCode)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; var content = await response.Content.ReadAsStringAsync();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; return content;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; //var error = await response.Content.ReadAsStringAsync(); // NOTE: This code is used to retrieve the underlying 'REVEL_CSRF: tokens mismatch' error&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; throw new ApplicationException($"({response.StatusCode}): {response.ReasonPhrase}");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is being used in a Console application running in the context of my domain account.&amp;nbsp; This domain account has been setup in NPrinting as a user with the 'Administrator' security role.&amp;nbsp; I've also ensured that the user has been linked with my domain account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c#" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14811390100589556 jive_text_macro" jivemacro_uid="_14811390100589556"&gt;
&lt;P&gt;var service = new NPrintingService(ConfigurationManager.AppSettings["ServiceUrl"]);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;var authenticate = await service.Authenticate();&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;var result = await service.CreateOnDemandRequest(); // Exception occurs here&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can confirm that the request is &lt;STRONG&gt;successfully authenticated&lt;/STRONG&gt;.&amp;nbsp; I've also run this code with Fiddler active and confirmed that the output is the same -- Authentication is successful, but creating the On-Demand request fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone been able to successfully use this API?&amp;nbsp; If so, how?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:40:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223136#M13348</guid>
      <dc:creator />
      <dc:date>2019-09-25T18:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223137#M13349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One discrepancy I noticed in Fiddler is that after performing the initial Authentication call that the Cookie: NPWEBCONSOLE_SESSION was not the same for the POST request, though it was the same as the GET requests.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET Request:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2b959abceaaf4b269651180bae7834ffda463955&lt;/STRONG&gt;-_TS:sessionuserid:e66d500966df4d96b9eb52989c13d931NPWEBCONSOLE_XSRF-TOKEN:I/z1TsYFYSOO2P3T/DrgI7IpJt0DTuiWadLOx09YoFQ=&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;POST Request:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;5faf8b88b0e99baa0681b3ad51658564cc6cfa27&lt;/STRONG&gt;-NPWEBCONSOLE_XSRF-TOKEN:I/z1TsYFYSOO2P3T/DrgI7IpJt0DTuiWadLOx09YoFQ=_TS:sessionuserid:e66d500966df4d96b9eb52989c13d931&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've revised my code so that after the Authentication request the NPWEBCONSOLE_XSRF-TOKEN and NPWEBCONSOLE_SESSION cookie values are pulled from the response and then used on each subsequent request, and have confirmed through Fiddler that the cookie values are now consistent amongst all request types, but I still get the same error as before (&lt;STRONG&gt;REVEL_CSRF: tokens mismatch&lt;/STRONG&gt;).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2016 21:05:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223137#M13349</guid>
      <dc:creator />
      <dc:date>2016-12-07T21:05:29Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223138#M13350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Short Answer&lt;/STRONG&gt;: Your requests need to include the custom HTTP header X-XSRF-TOKEN.&amp;nbsp; The value of this header will be identical to the value of the NPWEBCONSOLE_XSRF-TOKEN cookie.&amp;nbsp; For example (taken from Fiddler, which will successfully submit an OnDemand request)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;POST &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://REDACTED/api/v1/ondemand/requests" rel="nofollow" target="_blank"&gt;https://REDACTED/api/v1/ondemand/requests&lt;/A&gt;&lt;SPAN&gt; HTTP/1.1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Accept: application/json&lt;/P&gt;&lt;P&gt;X-XSRF-TOKEN: 9z80xdFG/9T+xhKUmBFlFxVOCbkjqimdW+iuUZtXtl4=&lt;/P&gt;&lt;P&gt;Content-Type: application/json; charset=utf-8&lt;/P&gt;&lt;P&gt;Host: REDACTED&lt;/P&gt;&lt;P&gt;Cookie: NPWEBCONSOLE_XSRF-TOKEN=9z80xdFG/9T+xhKUmBFlFxVOCbkjqimdW+iuUZtXtl4=; NPWEBCONSOLE_SESSION=71512e89749096debeeaa8eb3583f508570e1df6-%00NPWEBCONSOLE_XSRF-TOKEN%3A9z80xdFG%2F9T%2BxhKUmBFlFxVOCbkjqimdW%2BiuUZtXtl4%3D%00%00_TS%3Asession%00%00userid%3Ae66d500966df4d96b9eb52989c13d931%00&lt;/P&gt;&lt;P&gt;Content-Length: 100&lt;/P&gt;&lt;P&gt;Expect: 100-continue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"Config":{"OutputFormat":"HTML","ReportId":"595d3ca8-ff7a-4199-98ad-dc55e6004b6c"},"Type":"Report"}&lt;/P&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;&lt;P&gt;&lt;STRONG&gt;Long Answer&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The only other instance of this error I could find was for the source for a GO library at (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://github.com/cbonello/revel-csrf/blob/master/csrf.go" rel="nofollow" target="_blank"&gt;https://github.com/cbonello/revel-csrf/blob/master/csrf.go&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up decompiling the NPrinting Server WebEngine (which is built using the .NET Framework) and found in the Startup class the following snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;directoryName.EnvironmentVariables["GOPATH"] = fileInfo.DirectoryName;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which gave me a clue that the application was actually using something built in GO.&amp;nbsp; This turned out to be a proxy that sits in front of the WebEngine to validate requests.&amp;nbsp; The application executable is located at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Program Files\NPrintingServer\proxy\webconsoleproxy\&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To help diagnose the problem I enabled additional loggin in the app.config, located at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Program Files\NPrintingServer\proxy\webconsoleproxy\src\qlik.com\webconsoleproxy\conf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To enable logging, the following changes were made to the end of the conf:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;log.trace.output = %(app.name)s.log&lt;/P&gt;&lt;P&gt;log.info.output&amp;nbsp; = %(app.name)s.log&lt;/P&gt;&lt;P&gt;log.warn.output&amp;nbsp; = %(app.name)s.log&lt;/P&gt;&lt;P&gt;log.error.output = %(app.name)s.log&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could then see that the library was missing a token from the client:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRACE 2016/12/08 11:26:44 csrf.go:56: CSRF Filter: cookie found, value: jTmzEhFFnxRGlm11lv3w2zoIuGIxMCbCHb5TjD6B5iE=&lt;/P&gt;&lt;P&gt;TRACE 2016/12/08 11:26:44 csrf.go:100: REVEL-CSRF: Processing unsafe 'POST' method...&lt;/P&gt;&lt;P&gt;TRACE 2016/12/08 11:26:44 csrf.go:128: REVEL-CSRF: Token received from client: ''&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reviewing the source of the CSRF.go file I found that it was expecting a header named X-XSRF-TOKEN.&amp;nbsp; Taking an intuitive step I used the same value returned from the NPrinting authentication cookie (NPWEBCONSOLE_XSRF-TOKEN) and was successful in getting the POST requests submitted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2016 20:33:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223138#M13350</guid>
      <dc:creator />
      <dc:date>2016-12-08T20:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223139#M13351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anthony,&lt;/P&gt;&lt;P&gt;great you figured out this issue, it solved my Problem,&lt;/P&gt;&lt;P&gt;however if I log off fom Server and log on with a different&lt;/P&gt;&lt;P&gt;Service account admin User the Problem still remains.&lt;/P&gt;&lt;P&gt;Do you have an idea?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chrome by the way never throws an error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2018 10:06:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223139#M13351</guid>
      <dc:creator>philipp_ebner</dc:creator>
      <dc:date>2018-01-11T10:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223140#M13352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I am having the same &lt;EM&gt;REVEL_CSRF: tokens mismatch. &lt;/EM&gt;issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I am in a slightly different scenario as I am trying to connect to the API via the qvRestConnector and the X-XSRF-TOKEN hint you published get no better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I managed to&amp;nbsp; do the login via qvRestConnector and I get the cookies values.&lt;/P&gt;&lt;P&gt;Those values are good as I can use them in a curl query and in this way I can see the task execution in the NPrinting Web Console :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;curl&amp;nbsp; -v -X POST&amp;nbsp; -k&lt;/TD&gt;&lt;TD&gt;&lt;A class="jive-link-external-small" href="https://" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;server name&amp;gt;:4993/api/v1/tasks/&amp;lt;task id&amp;gt;/executions -H "X-XSRF-TOKEN:%cookie2%" -H"Cookie:%cookie1%"&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;where cookie1 and cookie 2 are the strings I get from the login qcRestConnector query (in Qv).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But If I try to run the POST query to the &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;server name&amp;gt;:4993/api/v1/tasks/&amp;lt;task id&amp;gt;/executions using the Cookie queryheader variable and X-XSRF-TOKEN queryheader variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nothing happen on the server side and on the Qv side&lt;/P&gt;&lt;P&gt;I get a response that Qv is not able to handle/show (QVX....error)&lt;/P&gt;&lt;P&gt;Can you help me as I am struggling on that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2018 10:31:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223140#M13352</guid>
      <dc:creator>bc-thebruuu</dc:creator>
      <dc:date>2018-05-31T10:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223141#M13353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anthony,&lt;/P&gt;&lt;P&gt;Can you describe us what are the changes you made in the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;CSRF.go&lt;/SPAN&gt; file please?&lt;/P&gt;&lt;P&gt;I'm not a C# professional.&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Aurélien&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2018 14:17:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1223141#M13353</guid>
      <dc:creator>aurelien_thiery</dc:creator>
      <dc:date>2018-10-12T14:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: NPrinting 17.2.1 REST API - Create OnDemand Request</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1561645#M23228</link>
      <description>&lt;P&gt;There is a much simpler and easier way to invoke Qlik Nprint using REST or CURL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most of the tools we used to develop the Big Data Platform is installed on Linux. Qliksense and NPrint are the odd ones installed in Windows. We have work on a very narrow timeline to complete EOD and trigger Qliksense/Nprint tasks. Due to OS conflict, we run the tasks manually. Challenge in NPrint is, there are bunch of reports and different ways the tasks were created. It is what it is and I can't change that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We built a simple shell script with couple of curl commands to get this done seamlessly without impacting the security features offered in Nov 2018 release (AD)&lt;/P&gt;&lt;P&gt;1. Get the Auth token for the NTLM Creds --&amp;gt;&amp;nbsp;curl -X GET https://Server:4993/api/v1/login/ntlm -v --ntlm --negotiate -u domain\user:Pass&lt;/P&gt;&lt;P&gt;2. Fire the Post request to Task execution --&amp;gt; refer the following URL for more details on the headers and cookies list.&lt;/P&gt;&lt;P&gt;&lt;A href="https://qliksupport.force.com/articles/Basic/How-to-Authenticate-Connect-with-the-Qlik-NPrinting-API-in-Postman-with-NTLM-Authentication" target="_blank"&gt;https://qliksupport.force.com/articles/Basic/How-to-Authenticate-Connect-with-the-Qlik-NPrinting-API-in-Postman-with-NTLM-Authentication&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List of supported APIs --&amp;gt;&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/nprinting/November2017/APIs/NP+API/index.html?page=45" target="_blank"&gt;https://help.qlik.com/en-US/nprinting/November2017/APIs/NP+API/index.html?page=45&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 01:42:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/NPrinting-17-2-1-REST-API-Create-OnDemand-Request/m-p/1561645#M23228</guid>
      <dc:creator>sivarajkumar</dc:creator>
      <dc:date>2019-03-27T01:42:40Z</dc:date>
    </item>
  </channel>
</rss>

