<?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 Re: Qlik Sense rest API with changing login token in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1507622#M3393</link>
    <description>&lt;P&gt;Ahh. Well you can use WITH CONNECTION to pass a param from the POST to subsequent GETs. For example:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;LIB CONNECT TO 'CONNECT';
SET vRequestBody = '{"username":"foo","password":"bar"}';  
let vRequestBody = replace(vRequestBody,'"', chr(34)&amp;amp;chr(34)); 

RestConnectorMasterTable:
SQL SELECT 
	"Set-Cookie" as "Set-Cookie"
FROM JSON "_response_header" PK "__KEY__response_header"
WITH CONNECTION (   
    URL "URL://Path",   
    HTTPHEADER "Content-Type" "application/json",   
  BODY "$(vRequestBody)"  
  );
  
  
Let cookie = Peek('Set-Cookie',0,'RestConnectorMasterTable');
Let session_id = Trim(SubField(cookie,';',1));
Trace $(session_id); 
DROP TABLE RestConnectorMasterTable;
// Begin subsequent GET with the Cookie from the JSON response from earlier
let URL_path = 'URL://Path';
let vURL_path = replace(URL_path,'"', chr(34)&amp;amp;chr(34)); 
LIB CONNECT TO 'Workflow';

RestConnectorMasterTable:
SQL SELECT 
	"totalWorkflowCount",
	"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (   
    URL "$(URL_path)",
    HTTPHEADER "Cookie" "$(session_id)"  

  )   ;

[Workflowcount]:
LOAD	[totalWorkflowCount] AS [totalWorkflowCount]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 15 Nov 2018 22:59:32 GMT</pubDate>
    <dc:creator>Levi_Turner</dc:creator>
    <dc:date>2018-11-15T22:59:32Z</dc:date>
    <item>
      <title>Qlik Sense rest API with changing login token</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/123052#M674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know if it is possible to get data from an API where the login token changes with each login?`&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My case is the following: &lt;/P&gt;&lt;P&gt;To connect to the API I'm trying to connect to, I have two tokens, one which is for the current login and another one which I need to get a new token for the next time I login. That means that I need Qlik to save the second token for my next login so that I can get a new login-token and a refresh token.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2018 08:55:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/123052#M674</guid>
      <dc:creator>cecilieleonhard</dc:creator>
      <dc:date>2018-11-09T08:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Qlik Sense rest API with changing login token</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1506337#M3385</link>
      <description>&lt;P&gt;How do you get the token? For example is it&amp;nbsp;HMAC? Is it retrieved from a POST call? etc.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 14:24:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1506337#M3385</guid>
      <dc:creator>Levi_Turner</dc:creator>
      <dc:date>2018-11-14T14:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Qlik Sense rest API with changing login token</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1507285#M3392</link>
      <description>&lt;P&gt;Thanks for your reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is retrieved through a POST call.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 13:50:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1507285#M3392</guid>
      <dc:creator>cecilieleonhard</dc:creator>
      <dc:date>2018-11-15T13:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Qlik Sense rest API with changing login token</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1507622#M3393</link>
      <description>&lt;P&gt;Ahh. Well you can use WITH CONNECTION to pass a param from the POST to subsequent GETs. For example:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;LIB CONNECT TO 'CONNECT';
SET vRequestBody = '{"username":"foo","password":"bar"}';  
let vRequestBody = replace(vRequestBody,'"', chr(34)&amp;amp;chr(34)); 

RestConnectorMasterTable:
SQL SELECT 
	"Set-Cookie" as "Set-Cookie"
FROM JSON "_response_header" PK "__KEY__response_header"
WITH CONNECTION (   
    URL "URL://Path",   
    HTTPHEADER "Content-Type" "application/json",   
  BODY "$(vRequestBody)"  
  );
  
  
Let cookie = Peek('Set-Cookie',0,'RestConnectorMasterTable');
Let session_id = Trim(SubField(cookie,';',1));
Trace $(session_id); 
DROP TABLE RestConnectorMasterTable;
// Begin subsequent GET with the Cookie from the JSON response from earlier
let URL_path = 'URL://Path';
let vURL_path = replace(URL_path,'"', chr(34)&amp;amp;chr(34)); 
LIB CONNECT TO 'Workflow';

RestConnectorMasterTable:
SQL SELECT 
	"totalWorkflowCount",
	"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (   
    URL "$(URL_path)",
    HTTPHEADER "Cookie" "$(session_id)"  

  )   ;

[Workflowcount]:
LOAD	[totalWorkflowCount] AS [totalWorkflowCount]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Nov 2018 22:59:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Sense-rest-API-with-changing-login-token/m-p/1507622#M3393</guid>
      <dc:creator>Levi_Turner</dc:creator>
      <dc:date>2018-11-15T22:59:32Z</dc:date>
    </item>
  </channel>
</rss>

