<?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 Getting next token using Rest Connector in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Getting-next-token-using-Rest-Connector/m-p/1632467#M7760</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Hi All,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Need a little help.&amp;nbsp; I'm trying to extract data form Microsoft CRM365 using Rest Connector.&amp;nbsp; Microsoft limits me to 5000 row per pull with a max time limit of 60 minutes.&amp;nbsp; I need more than 60 minutes processing time so I'm trying to refresh the token however I'm not having any luck.&amp;nbsp; Does anyone see anything wrong with my script why it would not pull another token?&amp;nbsp; Sort of under the gun to get this to work.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=&lt;A href="https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=3600;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/czzzz%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD&lt;/A&gt;;";&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"token_type",&lt;BR /&gt;"expires_in",&lt;BR /&gt;"ext_expires_in",&lt;BR /&gt;"expires_on",&lt;BR /&gt;"not_before",&lt;BR /&gt;"resource",&lt;BR /&gt;"access_token"&lt;BR /&gt;FROM JSON (wrap on) "root";&lt;/P&gt;&lt;P&gt;[root]:&lt;BR /&gt;LOAD&lt;BR /&gt;[token_type],&lt;BR /&gt;[expires_in],&lt;BR /&gt;[ext_expires_in],&lt;BR /&gt;[expires_on],&lt;BR /&gt;[not_before],&lt;BR /&gt;[resource],&lt;BR /&gt;[access_token]&lt;BR /&gt;RESIDENT RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vToken = peek('access_token');&lt;BR /&gt;&lt;BR /&gt;LET vExpiresIn = peek('expires_in',0,'access_token');&lt;BR /&gt;LET vExpiresIn = peek('expires_on',0,'access_token');&lt;BR /&gt;LET vAccessToken = peek('access_token',0,'access_token');&lt;BR /&gt;LET vTokenExpires = num(timestamp(now()) + $(vExpiresIn)/86400);&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vURL = '&lt;A href="https://davey.api.crm.dynamics.com/api/data/v9.1/opportunities" target="_blank" rel="noopener"&gt;https://davey.api.crm.dynamics.com/api/data/v9.1/zopportunities&lt;/A&gt;';&lt;/P&gt;&lt;P&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=$(vURL);timeout=3600;method=GET;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryParameters=$filter%2davey_contractstartdate ge 2019-01-01 and davey_proposaltype eq 2;queryHeaders=OData-Version%24.0%1OData-MaxVersion%24.0%1Authorization%2Bearer $(vToken);PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=FDQJXMC;XPassword=EWcUPYA;";&lt;BR /&gt;&lt;BR /&gt;DO while LEN(vURL) &amp;gt; 0&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"@odata.context",&lt;BR /&gt;"@odata.nextLink",&lt;BR /&gt;"__KEY_root",&lt;BR /&gt;(SELECT&lt;BR /&gt;"@odata.etag",&lt;BR /&gt;"createdon",&lt;BR /&gt;"opportunityid",&lt;BR /&gt;"__FK_value"&lt;BR /&gt;FROM "value" FK "__FK_value")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root"&lt;BR /&gt;WITH CONNECTION (Url "$(vURL)");&lt;/P&gt;&lt;P&gt;[Opportunity]:&lt;BR /&gt;LOAD&lt;BR /&gt;[@odata.etag],&lt;BR /&gt;[createdon],&lt;BR /&gt;[opportunityid],&lt;BR /&gt;[__FK_value] AS [__KEY_root]&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__FK_value]);&lt;/P&gt;&lt;P&gt;STORE * FROM [RestConnectorMasterTable] into QVD\Opportunity365.QVD;&lt;/P&gt;&lt;P&gt;LET vCount = FieldValueCount('@odata.nextLink');&lt;BR /&gt;LET vURL_new = FieldValue('@odata.nextLink', vCount);&lt;/P&gt;&lt;P&gt;IF vTokenExpires &amp;lt;= Num(now()) THEN&lt;BR /&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=&lt;A href="https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=1800;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=1800;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FzzRRfAdD&lt;/A&gt;;";&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"token_type",&lt;BR /&gt;"expires_in",&lt;BR /&gt;"ext_expires_in",&lt;BR /&gt;"expires_on",&lt;BR /&gt;"not_before",&lt;BR /&gt;"resource",&lt;BR /&gt;"access_token"&lt;BR /&gt;FROM JSON (wrap on) "root";&lt;/P&gt;&lt;P&gt;[root]:&lt;BR /&gt;LOAD&lt;BR /&gt;[token_type],&lt;BR /&gt;[expires_in],&lt;BR /&gt;[ext_expires_in],&lt;BR /&gt;[expires_on],&lt;BR /&gt;[not_before],&lt;BR /&gt;[resource],&lt;BR /&gt;[access_token]&lt;BR /&gt;RESIDENT RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vToken = peek('access_token');&lt;BR /&gt;LET vExpiresIn = peek('expires_in',0,'access_token');&lt;BR /&gt;LET vAccessToken = peek('access_token',0,'access_token');&lt;BR /&gt;LET vTokenExpires = Num(timestamp(now() + $(vExpiresIn)/86400));&lt;BR /&gt;&lt;BR /&gt;LET vToken = peek('access_token');&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;BR /&gt;end if&lt;/P&gt;&lt;P&gt;IF(vURL &amp;lt;&amp;gt; vURL_new) then&lt;BR /&gt;vURL = vURL_new;&lt;BR /&gt;ELSEIF(vURL = vURL_new) then&lt;BR /&gt;vURL = '';&lt;BR /&gt;end if&lt;BR /&gt;&lt;BR /&gt;Trace $(vURL);&lt;/P&gt;&lt;P&gt;Loop&lt;/P&gt;&lt;P&gt;DROP TABLE RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;DROP TABLE OpportunityProducts;&lt;/P&gt;&lt;P&gt;DROP TABLE product_opportunities;&lt;/P&gt;&lt;P&gt;Exit SCRIPT;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Dec 2021 14:42:54 GMT</pubDate>
    <dc:creator>tmumaw</dc:creator>
    <dc:date>2021-12-23T14:42:54Z</dc:date>
    <item>
      <title>Getting next token using Rest Connector</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Getting-next-token-using-Rest-Connector/m-p/1632467#M7760</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hi All,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Need a little help.&amp;nbsp; I'm trying to extract data form Microsoft CRM365 using Rest Connector.&amp;nbsp; Microsoft limits me to 5000 row per pull with a max time limit of 60 minutes.&amp;nbsp; I need more than 60 minutes processing time so I'm trying to refresh the token however I'm not having any luck.&amp;nbsp; Does anyone see anything wrong with my script why it would not pull another token?&amp;nbsp; Sort of under the gun to get this to work.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=&lt;A href="https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=3600;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/czzzz%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD&lt;/A&gt;;";&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"token_type",&lt;BR /&gt;"expires_in",&lt;BR /&gt;"ext_expires_in",&lt;BR /&gt;"expires_on",&lt;BR /&gt;"not_before",&lt;BR /&gt;"resource",&lt;BR /&gt;"access_token"&lt;BR /&gt;FROM JSON (wrap on) "root";&lt;/P&gt;&lt;P&gt;[root]:&lt;BR /&gt;LOAD&lt;BR /&gt;[token_type],&lt;BR /&gt;[expires_in],&lt;BR /&gt;[ext_expires_in],&lt;BR /&gt;[expires_on],&lt;BR /&gt;[not_before],&lt;BR /&gt;[resource],&lt;BR /&gt;[access_token]&lt;BR /&gt;RESIDENT RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vToken = peek('access_token');&lt;BR /&gt;&lt;BR /&gt;LET vExpiresIn = peek('expires_in',0,'access_token');&lt;BR /&gt;LET vExpiresIn = peek('expires_on',0,'access_token');&lt;BR /&gt;LET vAccessToken = peek('access_token',0,'access_token');&lt;BR /&gt;LET vTokenExpires = num(timestamp(now()) + $(vExpiresIn)/86400);&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vURL = '&lt;A href="https://davey.api.crm.dynamics.com/api/data/v9.1/opportunities" target="_blank" rel="noopener"&gt;https://davey.api.crm.dynamics.com/api/data/v9.1/zopportunities&lt;/A&gt;';&lt;/P&gt;&lt;P&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=$(vURL);timeout=3600;method=GET;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryParameters=$filter%2davey_contractstartdate ge 2019-01-01 and davey_proposaltype eq 2;queryHeaders=OData-Version%24.0%1OData-MaxVersion%24.0%1Authorization%2Bearer $(vToken);PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=FDQJXMC;XPassword=EWcUPYA;";&lt;BR /&gt;&lt;BR /&gt;DO while LEN(vURL) &amp;gt; 0&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"@odata.context",&lt;BR /&gt;"@odata.nextLink",&lt;BR /&gt;"__KEY_root",&lt;BR /&gt;(SELECT&lt;BR /&gt;"@odata.etag",&lt;BR /&gt;"createdon",&lt;BR /&gt;"opportunityid",&lt;BR /&gt;"__FK_value"&lt;BR /&gt;FROM "value" FK "__FK_value")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root"&lt;BR /&gt;WITH CONNECTION (Url "$(vURL)");&lt;/P&gt;&lt;P&gt;[Opportunity]:&lt;BR /&gt;LOAD&lt;BR /&gt;[@odata.etag],&lt;BR /&gt;[createdon],&lt;BR /&gt;[opportunityid],&lt;BR /&gt;[__FK_value] AS [__KEY_root]&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__FK_value]);&lt;/P&gt;&lt;P&gt;STORE * FROM [RestConnectorMasterTable] into QVD\Opportunity365.QVD;&lt;/P&gt;&lt;P&gt;LET vCount = FieldValueCount('@odata.nextLink');&lt;BR /&gt;LET vURL_new = FieldValue('@odata.nextLink', vCount);&lt;/P&gt;&lt;P&gt;IF vTokenExpires &amp;lt;= Num(now()) THEN&lt;BR /&gt;CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=&lt;A href="https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=1800;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FRRfAdD" target="_blank" rel="noopener"&gt;https://login.microsoftonline.com/c4a8639a-d5a9-4b9a-aa77-c15cb9c9b6b2/oauth2/token;timeout=1800;method=POST;requestBody=client_id%244d54725-49d3-4966-93cb-c26fcd804ade&amp;amp;grant_type%2client_credentials&amp;amp;resource%2https%%3A%%2F%%2Fdavey.api.crm.dynamics.com%%2F&amp;amp;client_secret%2b7zqDA0tJh0nuk7imXGYnkGRqrV9ycRE1L6H5elld%%2Bk%%3D;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStoreName=My;queryHeaders=Content-Type%2application/x-www-form-urlencoded;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=TMXZBGC;XPassword=FzzRRfAdD&lt;/A&gt;;";&lt;BR /&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"token_type",&lt;BR /&gt;"expires_in",&lt;BR /&gt;"ext_expires_in",&lt;BR /&gt;"expires_on",&lt;BR /&gt;"not_before",&lt;BR /&gt;"resource",&lt;BR /&gt;"access_token"&lt;BR /&gt;FROM JSON (wrap on) "root";&lt;/P&gt;&lt;P&gt;[root]:&lt;BR /&gt;LOAD&lt;BR /&gt;[token_type],&lt;BR /&gt;[expires_in],&lt;BR /&gt;[ext_expires_in],&lt;BR /&gt;[expires_on],&lt;BR /&gt;[not_before],&lt;BR /&gt;[resource],&lt;BR /&gt;[access_token]&lt;BR /&gt;RESIDENT RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;LET vToken = peek('access_token');&lt;BR /&gt;LET vExpiresIn = peek('expires_in',0,'access_token');&lt;BR /&gt;LET vAccessToken = peek('access_token',0,'access_token');&lt;BR /&gt;LET vTokenExpires = Num(timestamp(now() + $(vExpiresIn)/86400));&lt;BR /&gt;&lt;BR /&gt;LET vToken = peek('access_token');&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;BR /&gt;end if&lt;/P&gt;&lt;P&gt;IF(vURL &amp;lt;&amp;gt; vURL_new) then&lt;BR /&gt;vURL = vURL_new;&lt;BR /&gt;ELSEIF(vURL = vURL_new) then&lt;BR /&gt;vURL = '';&lt;BR /&gt;end if&lt;BR /&gt;&lt;BR /&gt;Trace $(vURL);&lt;/P&gt;&lt;P&gt;Loop&lt;/P&gt;&lt;P&gt;DROP TABLE RestConnectorMasterTable;&lt;/P&gt;&lt;P&gt;DROP TABLE OpportunityProducts;&lt;/P&gt;&lt;P&gt;DROP TABLE product_opportunities;&lt;/P&gt;&lt;P&gt;Exit SCRIPT;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 14:42:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Getting-next-token-using-Rest-Connector/m-p/1632467#M7760</guid>
      <dc:creator>tmumaw</dc:creator>
      <dc:date>2021-12-23T14:42:54Z</dc:date>
    </item>
  </channel>
</rss>

