<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>api pagination Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/api-pagination/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/api-pagination/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 19 Mar 2026 23:09:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>api pagination Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/api-pagination/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to read data from ServiceNow REST API using SSIS</title>
		<link>https://zappysys.com/blog/how-to-read-data-from-servicenow-rest-api-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 13 Mar 2017 19:40:38 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[api pagination]]></category>
		<category><![CDATA[servicenow api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[ssis json source]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1081</guid>

					<description><![CDATA[<p>Introduction ServiceNow one of the most popular Incident management platform used by many. In this blog post you will learn how to get data from ServiceNow REST API using SSIS JSON Source (No coding required). You will also learn other API integration scenarios such as POST, DELETE, PUT API calls. You will also learn how to paginate [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/how-to-read-data-from-servicenow-rest-api-ssis/">How to read data from ServiceNow REST API using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>UPDATE:</strong> ZappySys has released a brand new <a href="https://zappysys.com/api/integration-hub/servicenow-connector/">API Connector for ServiceNow</a> which makes it much simpler to <a href="https://zappysys.com/api/integration-hub/servicenow-connector/ssis"><strong>Read/Write ServiceNow Data in SSIS</strong></a> compared to the steps listed in this article. You can still use steps from this article but if you are new to API or want to avoid learning curve with API then use newer approach.</p>
<p>Please visit <a href="https://zappysys.com/api/integration-hub/">this page to see all</a> Pre-Configured ready to use API connectors which you can use in <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-source/">SSIS API Source</a> / <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-destination/">SSIS API Destination</a> OR <a href="https://zappysys.com/products/odbc-powerpack/odbc-api-driver/">API ODBC Driver</a> (for non-SSIS Apps such as Excel, Power BI, Informatica).<br />
</div></div>
<p><img loading="lazy" decoding="async" class="wp-image-1744 alignleft" src="//zappysys.com/blog/wp-content/uploads/2017/03/servicenow-api-integration.png" alt="" width="116" height="116" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/servicenow-api-integration.png 301w, https://zappysys.com/blog/wp-content/uploads/2017/03/servicenow-api-integration-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/03/servicenow-api-integration-300x300.png 300w" sizes="(max-width: 116px) 100vw, 116px" /></p>
<p>ServiceNow one of the most popular Incident management platform used by many. In this blog post you will learn how to get data from ServiceNow REST API using <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">SSIS JSON Source</a> (No coding required). You will also learn other API integration scenarios such as POST, DELETE, PUT API calls.</p>
<p>You will also learn how to paginate response if you have large amount of data (E.g. more than 10000 rows)</p>
<p>&nbsp;</p>
<h2><span id="Prerequisites">Prerequisites</span></h2>
<p>Before we look into Step-By-Step section to calling ServiceNow API in SSIS let’s make sure you met following requirements.</p>
<ol>
<li>SSIS designer installed. Sometimes it is referred as BIDS or SSDT (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from Microsoft site</a>).</li>
<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
<li><a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener"><em>ZappySys SSIS PowerPack</em> installed</a>. Click on the link to download FREE trial.</li>
<li>You have basic familiarity with ServiceNow API and you have UserID and Password handy.</li>
</ol>
<h3><span id="Prerequisites">Step-By-Step : Accessing ServiceNow data using SSIS</span></h3>
<p>Now lets look at how to fetch data from ServiceNow API using SSIS JSON Source.</p>
<h3>Configure SSIS HTTP Connection for ServiceNow REST API</h3>
<p>First step to access ServiceNow data is configure HTTP connection on JSON Source. In below example we will use <a href="https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/concept/c_RESTAPI.html" target="_blank" rel="noopener"><strong>ServiceNow REST API</strong></a>. There are many endpoints for ServiceNow REST API but we will use <a href="http://wiki.servicenow.com/index.php?title=Table_API" target="_blank" rel="noopener">Table API Service</a> to query table. Now lets look at steps to configure ServiceNow API connection</p>
<ol>
<li>Open SSIS Package and go to Data Flow designer (Click new data flow if missing)</li>
<li>Drag and drop  <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">ZS JSON Source</a> from SSIS Data Flow Toolbox</li>
<li>Double click JSON Source to configure it as below
<ol>
<li>First Enter Full URL to access desired API. For example you can enter URL like below (We entered sysparm_limit=2000 to fetch 2000 records in each response. Change this to higher limit to speed up data extract. This number must match on Pagination tab &#8211; see next section). Change <strong>instance001</strong> to your own instance name.<br />
<pre class="crayon-plain-tag">https://instance001.service-now.com/api/now/v2/table/incident?sysparm_limit=2000</pre>
</li>
<li>Check Use Credentials option</li>
<li>Click New Connection and configure HTTP connection like below. Once done click OK
<div id="attachment_11188" style="width: 770px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-with-basic-auth.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11188" src="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-with-basic-auth.png" alt="ssis-servicenow-rest-api-with-basic-auth" width="760" height="803" class="size-full wp-image-11188" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-with-basic-auth.png 760w, https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-with-basic-auth-284x300.png 284w" sizes="(max-width: 760px) 100vw, 760px" /></a><p id="caption-attachment-11188" class="wp-caption-text">Configure ServiceNow REST API Connection in SSIS (Basic Auth using UserID, Password)</p></div></li>
<li>Click on Select Filter or enter <strong>$.result[*]</strong> in the filter textbox
<div id="attachment_1738" style="width: 1074px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1738" class="size-full wp-image-1738" src="//zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api.png" alt="Configure SSIS JSON for ServiceNow REST API - Read data from Table" width="1064" height="741" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api.png 1064w, https://zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api-300x209.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api-768x535.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/03/configure-ssis-json-source-servicenow-rest-api-1024x713.png 1024w" sizes="(max-width: 1064px) 100vw, 1064px" /></a><p id="caption-attachment-1738" class="wp-caption-text">Configure SSIS JSON for ServiceNow REST API &#8211; Read data from Table</p></div></li>
</ol>
</li>
<li>Click Preview to see some data. In next section we will configure Pagination to fetch many records.</li>
<li>If you like to load data to SQL Server then Simply connect your JSON Source to OLEDB Destination and Create New Table &gt; Click Mappings and Click OK</li>
<li>Execute Package</li>
</ol>
<p>&nbsp;</p>
<h3>Configure JSON Source for ServiceNow API Pagination</h3>
<p>By default ServiceNow API doesn&#8217;t return all records from your table. So if you wish to get all records then you must configure Pagination settings like below. For more information on pagination in SSIS <a href="//zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">read this article</a>.</p>
<div id="attachment_11189" style="width: 770px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-RFC5988-pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11189" src="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-RFC5988-pagination.png" alt="ServiceNow REST API Pagination in SSIS" width="760" height="727" class="size-full wp-image-11189" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-RFC5988-pagination.png 760w, https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-rest-api-RFC5988-pagination-300x287.png 300w" sizes="(max-width: 760px) 100vw, 760px" /></a><p id="caption-attachment-11189" class="wp-caption-text">ServiceNow REST API RFC-5988 Pagination in SSIS</p></div>
<p>Once you configure API Pagination it will keep fetching data from new URL automatically until no more data found or it hit Max Row limit you specify on UI (In our case we did max 100 rows). Use <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">tool like Fiddler</a> to view HTTP requests made by JSON Source.</p>
<div id="attachment_1742" style="width: 782px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/03/fiddler-log-api-pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1742" class="size-full wp-image-1742" src="//zappysys.com/blog/wp-content/uploads/2017/03/fiddler-log-api-pagination.png" alt="Debugging Web API requests using Fiddler" width="772" height="189" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/fiddler-log-api-pagination.png 772w, https://zappysys.com/blog/wp-content/uploads/2017/03/fiddler-log-api-pagination-300x73.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/03/fiddler-log-api-pagination-768x188.png 768w" sizes="(max-width: 772px) 100vw, 772px" /></a><p id="caption-attachment-1742" class="wp-caption-text">Debugging Web API requests using Fiddler</p></div>
<h3>Configure JSON Source for ServiceNow JSONv2 Pagination (older version API)</h3>
<p>In this section you will learn how to use older version of API known as <a href="https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/integrate/inbound-other-web-services/concept/c_JSONv2WebService.html" target="_blank" rel="noopener">ServiceNow JSONv2 Service</a> (another <a href="http://wiki.servicenow.com/index.php?title=JSONv2_Web_Service#gsc.tab=0" target="_blank" rel="noopener">help link here</a>). Syntax for ServiceNow JSONv2 API is below to access table data.</p><pre class="crayon-plain-tag">https://&lt;instance name&gt;.service-now.com/mytable.do?JSONv2
Or
https://&lt;instance name&gt;.service-now.com/mytable.do?JSONv2&amp;param1=val1&amp;param2=val2....</pre><p>
Now lets look at steps to configure ServiceNow API connection</p>
<p>To configure JSONv2 API use above steps for most of the things except following settings</p>
<ol>
<li>Configure URL like below (assuming you want to query sys_db_object table, with 15 record max in each response)<br />
<pre class="crayon-plain-tag">https://instance001.service-now.com/sys_db_object.do?JSONv2&amp;sysparm_record_count=15&amp;sysparm_query=ws_access=true^sys_mod_count=1^ORDERBYsys_id</pre>
</li>
<li>Configure Pagination Settings like below
<ol>
<li>Select Mode = Response Attribute Mode</li>
<li>For NextLink Enter <strong>$.records[-1:].sys_id</strong></li>
<li>For Suffix for Next URL enter <strong>&amp;sysparm_query=sys_id&gt;&lt;%nextlink%&gt;^ws_access=true^sys_mod_count=1^ORDERBYsys_id</strong></li>
<li>For Filter enter <strong>$.records[*]</strong></li>
</ol>
</li>
</ol>
<p><a href="//zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-jsonv2-rest-api-pagination.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1743" src="//zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-jsonv2-rest-api-pagination.png" alt="" width="903" height="819" srcset="https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-jsonv2-rest-api-pagination.png 903w, https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-jsonv2-rest-api-pagination-300x272.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/03/ssis-servicenow-jsonv2-rest-api-pagination-768x697.png 768w" sizes="(max-width: 903px) 100vw, 903px" /></a></p>
<h2><span id="Loading_Graph_API_Office_365_data_to_SQL_Server">Loading ServiceNow data to SQL Server</span></h2>
<p>Once you done configuring JSON Source you can  load data to SQL Server. For example purpose we will load data into SQL Server but you can load into any Target (e.g. Flat file, Oracle, Excel) using Microsoft or ZappySys Destination connectors</p>
<p>To load ServiceNow data into SQL Server perform the following steps (Screenshot is used for demonstration for purpose, your values can be different than below)</p>
<ol>
<li>Drag OLEDB destination on Data Flow surface</li>
<li>Connect ZS JSON Source to Destination</li>
<li>On OLEDB destination select / create new SQL Connection and then Click “New Table”</li>
<li>Click on Mappings tab and click OK to save</li>
<li>Execute Package</li>
</ol>
<div id="attachment_1617" class="wp-caption alignnone">
<p><a href="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png"><img loading="lazy" decoding="async" class="size-full wp-image-1617" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?resize=720%2C546" sizes="(max-width: 720px) 100vw, 720px" srcset="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?w=782 782w, https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?resize=300%2C227 300w, https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?resize=768%2C582 768w" alt="Configure SSIS OLEDB Destination - Loading Xero Data into SQL Server Table" width="702" height="532" data-attachment-id="1617" data-permalink="//zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/ssis-xero-to-sql-server-data-load/#main" data-orig-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?fit=782%2C593" data-orig-size="782,593" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ssis-xero-to-sql-server-data-load" data-image-description="&lt;p&gt;Configure SSIS OLEDB Destination – Loading Xero Data into SQL Server Table&lt;/p&gt; " data-medium-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?fit=300%2C227" data-large-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png?fit=720%2C546" /></a></p>
<p class="wp-caption-text">Configure SSIS OLEDB Destination – Loading ServiceNow Data into SQL Server Table</p>
</div>
<div id="attachment_1618" class="wp-caption alignnone">
<p><a href="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png"><img loading="lazy" decoding="async" class="size-full wp-image-1618" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?resize=720%2C533" sizes="(max-width: 720px) 100vw, 720px" srcset="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?w=734 734w, https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?resize=300%2C222 300w" alt="Xero to SQL Server Column Mappings for OLEDB Destination" width="702" height="519" data-attachment-id="1618" data-permalink="//zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/ssis-xero-sql-server-load-mappings/#main" data-orig-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?fit=734%2C543" data-orig-size="734,543" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ssis-xero-sql-server-load-mappings" data-image-description="&lt;p&gt;Xero to SQL Server Column Mappings for OLEDB Destination&lt;/p&gt; " data-medium-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?fit=300%2C222" data-large-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png?fit=720%2C533" /></a></p>
<p class="wp-caption-text">ServiceNow API to SQL Server Column Mappings for OLEDB Destination</p>
</div>
<div id="attachment_1619" class="wp-caption alignnone">
<p><a href="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png"><img loading="lazy" decoding="async" class="size-full wp-image-1619" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?resize=283%2C391" sizes="(max-width: 283px) 100vw, 283px" srcset="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?w=283 283w, https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?resize=217%2C300 217w" alt="Loading Xero data to SQL Server in SSIS" width="275" height="380" data-attachment-id="1619" data-permalink="//zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/ssis-loading-data-from-xero-to-sql-server/#main" data-orig-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?fit=283%2C391" data-orig-size="283,391" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ssis-loading-data-from-xero-to-sql-server" data-image-description="&lt;p&gt;Loading Xero data to SQL Server in SSIS&lt;/p&gt; " data-medium-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?fit=217%2C300" data-large-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png?fit=283%2C391" /></a></p>
<p class="wp-caption-text">Loading ServiceNow REST API to SQL Server in SSIS</p>
</div>
<h2>POST Data to ServiceNow API (Insert, Update or Delete)</h2>
<p>There will be a time you like to automate POST actions (e.g. create new incident via API call). <a href="//zappysys.com/blog/http-post-in-ssis-send-data-to-web-api-url-json-xml/" target="_blank" rel="noopener">Check this article</a> to learn more on how to POST , DELETE, PUT data using API calls</p>
<h2>Common Errors</h2>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2>Deployment to Production</h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<h2><span id="ConclusionWhats_next"><span id="ConclusionWhat8217s_next">Conclusion. What’s next?</span></span></h2>
<p>In this article we have learned how to load data from ServiceNow API to SQL Server using SSIS ( drag and drop approach without coding). We used <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS JSON / REST API Connector</a> to extract data from ServiceNow table. JSON Source Connector makes it super simple to parsing complex / large JSON Files or any Web API Response into rows and column so you can load into database like SQL Server. <a href="//zappysys.com/products/ssis-powerpack/">Download SSIS PowerPack</a> to try many other automation scenarios not discussed in this article.</p>
<p><strong>Keywords:</strong></p>
<p>ServiceNow Integration with SQL Server | How to extract ServiceNow data in SSIS? | How to read ServiceNow table? | Calling ServiceNow REST API using SSIS. | ServiceNow to SQL Server | SQL Server to ServiceNow | SSIS ServiceNow API Integration | ServiceNow SOAP API Integration</p>
<p>The post <a href="https://zappysys.com/blog/how-to-read-data-from-servicenow-rest-api-ssis/">How to read data from ServiceNow REST API using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to do REST API Pagination in SSIS / ODBC Drivers</title>
		<link>https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/</link>
					<comments>https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/#comments</comments>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Fri, 08 Apr 2016 15:37:55 +0000</pubDate>
				<category><![CDATA[SSIS Components]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[SSIS XML Source (File / SOAP)]]></category>
		<category><![CDATA[api pagination]]></category>
		<category><![CDATA[json source]]></category>
		<category><![CDATA[looping]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[xml source]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=422</guid>

					<description><![CDATA[<p>Introduction In our previous blog, we saw how to call REST in SSIS including concepts of Authentication / Error Handling. Now in this post, we will cover API Pagination. You will learn concepts and patterns about REST API Pagination (for JSON / XML / SOAP or CSV API). We will describe methods and steps to implement REST API [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/">How to do REST API Pagination in SSIS / ODBC Drivers</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In our previous blog, we saw <a href="https://zappysys.com/blog/call-rest-api-using-ssis-web-service-task/">how to call REST in SSIS</a> including concepts of Authentication / Error Handling. Now in this post, <strong>we will cover API Pagination.</strong> You will learn concepts and patterns about REST API Pagination (for JSON / XML / SOAP or CSV API).</p>
<p>We will describe methods and steps to implement REST API Pagination in SSIS PowerPack or  <a href="https://zappysys.com/products/odbc-powerpack/">ODBC PowerPack API Drivers (for apps like Excel, Power BI, Informatica&#8230;)</a> without coding. Both Products share a similar user interface with minor differences. For example purpose, we will show screenshots from SSIS PowerPack UI but concepts should remain same. You will also learn some techniques about <strong>how to implement an infinite loop in SSIS</strong>. Sometimes your REST API requires you to loop through all pages until no more data found then you can use pattern described in this article (sample package attached at the end).</p>
<p>In this article, we will use <a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/">SSIS REST API Task</a> and <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON Source Connector</a> to process data from RESTful web service. If you have to process XML (or SOAP) data from REST API then simply use <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/">XML Source Connector for REST API, SOAP or File</a> rather than JSON Source.</p>
<h2>Debugging REST API Requests</h2>
<p>Before we look at various aspects of REST API Pagination, we highly recommend you install FREE Web Debugging Tool Fiddler. <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Look at this article</a> to understand how to debug REST API requests.</p>
<h2>Method-1: REST API Pagination via URL Parameter</h2>
<p>If you have paging requirement by specifying page number in URL then you can loop until no more pages found. Your REST API can indicate no more page found by any of the following ways.</p>
<p><strong>Example URL: </strong> http://myserver.com/v1/api/getcustomers/?<strong>page=1</strong></p>
<p>If no more data found for specified page number then</p>
<ol>
<li>server may return an empty response</li>
<li>server may return the response with specific error and response status code</li>
</ol>
<p><a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON Source Connector</a> comes with flexible paging options to handle this scenario. See below screenshot how to configure this.</p>
<div id="attachment_10740" style="width: 777px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-1-JSON-source-Pagination-URL-parameter-mode.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10740" class="size-full wp-image-10740" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-1-JSON-source-Pagination-URL-parameter-mode.png" alt="Pagination Method 1 URL parameter mode" width="767" height="730" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-1-JSON-source-Pagination-URL-parameter-mode.png 767w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-1-JSON-source-Pagination-URL-parameter-mode-300x286.png 300w" sizes="(max-width: 767px) 100vw, 767px" /></a><p id="caption-attachment-10740" class="wp-caption-text">REST API Looping/Pagination via URL Page Number Parameter (Loop until last page detected)</p></div>
<p><strong>URL with offset and limit</strong></p>
<p>Sometimes you may have URLs with offset + limit parameters. as below. In this case, you can use the same technique as the above screenshot but just specify Page Num Indicator as <strong>offset</strong> and Increment by the same as your limit parameter (e.g. 1000 in this case). At runtime, your offset parameter will increment and generate URLs like below to fetch the next page.</p>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">If you don&#8217;t specify the offset parameter in the initial URL then <strong>offset=1</strong> will be assumed as the default start. If your offset starts at 0 then refer to the next section for a workaround (i.e. Use URL Path Mode with StartAt variable = 0). Also if your increment for offset is other than the default page size then you must include the limit / pagesize parameter in the URL as below (e.g. limit=100 which is rows per page)</div></div>
<p><strong>Example URLs: </strong><br />
http://myserver.com/v1/api/getcustomers/?offset<strong>=1</strong>&amp;limit=1000<br />
http://myserver.com/v1/api/getcustomers/?offset=<strong>1001</strong>&amp;limit=1000<br />
http://myserver.com/v1/api/getcustomers/?offset=<strong>2001</strong>&amp;limit=1000</p>
<h2>Method-2: REST API Pagination via URL Path</h2>
<p>Sometimes your URL may contain a page or other identifier using path format.</p>
<p><strong>Example URLs: </strong><br />
http://myserver.com/v1/api/getcustomers/<strong>1/</strong><br />
http://myserver.com/v1/api/getcustomers/<strong>2</strong>/<br />
http://myserver.com/data/file<strong>1</strong>.json<br />
http://myserver.com/data/file<strong>2</strong>.json</p>
<p>If no more data is found for the specified page number then</p>
<ol>
<li>the server may return a 404 error (page not found)</li>
<li>server may return a response with a specific error and response status code</li>
</ol>
<p><a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON Source Connector</a> comes with flexible paging options to handle this scenario. See the below screenshot of how to configure this.</p>
<div id="attachment_10741" style="width: 785px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-JSON-source-Pagination-URL-path-mode-Page-number-offset-passed-as-URL-path.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10741" class="size-full wp-image-10741" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-JSON-source-Pagination-URL-path-mode-Page-number-offset-passed-as-URL-path.png" alt="Pagination Method 2 " width="775" height="479" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-JSON-source-Pagination-URL-path-mode-Page-number-offset-passed-as-URL-path.png 775w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-JSON-source-Pagination-URL-path-mode-Page-number-offset-passed-as-URL-path-300x185.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-JSON-source-Pagination-URL-path-mode-Page-number-offset-passed-as-URL-path-768x475.png 768w" sizes="(max-width: 775px) 100vw, 775px" /></a><p id="caption-attachment-10741" class="wp-caption-text">REST API Looping/Pagination via URL Path (Loop until last page detected)</p></div>
<h3>URL with Skip Parameter (Offset starts at zero)</h3>
<p>Now let&#8217;s look at another common pattern just like the offset we discussed earlier but in the Skip pattern, it starts at zero rather than offset=1. In the previous mode, we didn&#8217;t have the option to supply the initial value to start the counter but if you use Path mode then you can start the counter at some custom value. See the below screen to show how we can setup pagination with the skip method with custom increment.</p>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">If your increment for offset is other than the default page size then you must include page size parameter in the URL as below (e.g. pagesize=100 which is rows per page. Some APIs name this parameter in different way e.g. count=1000 or limit=100. Refer to the API documentation to know exact names)</div></div>
<p><strong>Example URLs</strong></p><pre class="crayon-plain-tag">http://mysite.com/api/getorders?skip=0&amp;pagesize=100
http://mysite.com/api/getorders?skip=100&amp;pagesize=100
http://mysite.com/api/getorders?skip=200&amp;pagesize=100
http://mysite.com/api/getorders?skip=300&amp;pagesize=100
....</pre><p>
<div id="attachment_10742" style="width: 1098px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10742" class="size-full wp-image-10742" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter.png" alt="Pagination method 2 URL with Skip Parameter" width="1088" height="481" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter.png 1088w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter-300x133.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter-768x340.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-2-Pagination-URL-with-Skip-Parameter-1024x453.png 1024w" sizes="(max-width: 1088px) 100vw, 1088px" /></a><p id="caption-attachment-10742" class="wp-caption-text">REST API Pagination with Custom Skip / Increment Settings (Offset Starts from 0)</p></div>
<p>&nbsp;</p>
<h2>Method-3 : REST API Pagination via Response Attribute (Next Link or Cursor)</h2>
<p>This method is not discussed in this article but <a href="https://zappysys.com/blog/odata-paging-rest-api-paging-using-ssis-json-source/" target="_blank" rel="noopener">click here to read more</a></p>
<p>There are mainly 3 ways you can get next link or cursor.</p>
<ol>
<li>Full Link (e.g. nextPage : &#8220;https://mysite.com/api/v1/1/?filter=AAAA&#8221; )</li>
<li>Partial Link  (e.g. nextPage : &#8220;/api/v1/getcustomer/1/?filter=AAAA&#8221; )</li>
<li>Cursor Continuation Token (e.g.   nextCursor : &#8220;xxxxAAAbbbbCccc112233==&#8221; )</li>
</ol>
<h3>Next Link Method (Partial or Full URL)</h3>
<p>Example response with next URL would be</p><pre class="crayon-plain-tag">{ 
  "value" : [....], 
  "odata.nextLink" : "http://abc.com/customers/2/" 
}</pre><p>
In this method you don&#8217;t specify page number in URL. If response include many records then you will get partial response along with indicator of next link.</p>
<p>For more information about this <em>REST API Pagination</em> please check below links. It explains in depth how to paginate REST API response with next page link found in response.</p>
<p><a title="Permalink to OData Paging using SSIS – REST API Paging Example" href="//zappysys.com/blog/odata-paging-rest-api-paging-using-ssis-json-source/" rel="bookmark">OData Paging using SSIS – REST API Paging Example</a></p>
<p><a title="Permalink to Read Twitter data in SSIS using REST API Task and JSON Source – OAuth2 Protocol" href="//zappysys.com/blog/read-twitter-data-in-ssis-using-rest-api-task-json-source-oauth2/#Handling_paging_of_large_REST_API_result_set_with_twitter_data_8211_loopingcursoring" rel="bookmark">Read Twitter data in SSIS using REST API Task and JSON Source – OAuth2 Protocol</a></p>
<div id="attachment_10743" style="width: 706px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-via-Response-Attribute-Next-Link-or-Cursor.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10743" class="size-full wp-image-10743" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-via-Response-Attribute-Next-Link-or-Cursor.png" alt="Method-3: Next Link Method (Partial or Full URL)" width="696" height="557" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-via-Response-Attribute-Next-Link-or-Cursor.png 696w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-via-Response-Attribute-Next-Link-or-Cursor-300x240.png 300w" sizes="(max-width: 696px) 100vw, 696px" /></a><p id="caption-attachment-10743" class="wp-caption-text">SSIS API Pagination – Next Link from Response Attribute</p></div>
<h3>Next Link &#8211; Detect the last page based on empty rows (Regular Expression)</h3>
<p>Now let&#8217;s look at a little bit different scenario where the Next Link is never empty even on the last page. This can cause an infinite loop if we configure it like the last section. So in such a case (see below example) when the last page still has the next link URL but the data row array is empty then use settings like the screenshot below.</p>
<p><strong>First Page Example</strong></p><pre class="crayon-plain-tag">{ 
  "value" : [....], 
  "odata.nextLink" : "http://abc.com/customers/2/" 
}</pre><p>
<strong>Last Page Example</strong></p><pre class="crayon-plain-tag">{ 
  "value" : [], 
  "odata.nextLink" : "http://abc.com/customers/NNNN/" 
}</pre><p>
<strong>Example: Last Page</strong></p>
<p>Basically, configure the following options</p>
<ul>
<li>Set <b>Stop indicator attribute</b> to the same node which contains data rows (without array brackets). E.g. <strong>$.items</strong></li>
<li>Set <b>Stop indicator value / Regular Expression </b>to something like <pre class="crayon-plain-tag">[]</pre>  assuming the last page has the same way. <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Check Fiddler Trace</a> for exact text on the last page.</li>
</ul>
<div id="attachment_10744" style="width: 678px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-Detect-the-last-page-based-on-empty-rows.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10744" class="size-full wp-image-10744" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-Detect-the-last-page-based-on-empty-rows.png" alt="Method-3 Detect the last page based on empty rows " width="668" height="399" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-Detect-the-last-page-based-on-empty-rows.png 668w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-3-Pagination-Detect-the-last-page-based-on-empty-rows-300x179.png 300w" sizes="(max-width: 668px) 100vw, 668px" /></a><p id="caption-attachment-10744" class="wp-caption-text">Last Page with non empty next link and empty data array (Detect Last Page based on zero row count)</p></div>
<h3>Cursor Method</h3>
<p>Many API returns cursor rather than link. Cursor method usually used to support a large number of records. Cursor is opened at server side with initial query information you submit and if cursor has more records you may get next cursor indicator in your response. In cursor method you have to supply Suffix for Next URL so after First URL your next URL will contain extra attribute which will include pagination information.</p>
<p><strong>Suffix for next URL</strong></p>
<p>Suffix for next URL can include special placeholders. There are two placeholders allowed. If you wish to append Next URL value in raw text then use <strong>&lt;%nextlink%&gt;</strong> but if your API needs value in encoded format e.g. A%20B rather than A+B then you have to use <strong>&lt;%nextlink_encoded%&gt;</strong></p>
<p><strong>Example URLs for Cursor:</strong></p>
<p>Below is few sample URLs in the log when pagination occurs via Cursor method. As you see the first URL has Cursor=* means its first call, after first request server may send next cursor in the response body (see example)</p><pre class="crayon-plain-tag">{ 
&nbsp; data: [....], 
&nbsp; nextCursor: &quot;Aooo/MxxxxxxxxxxxtdA==&quot; 
}</pre><p>
First URL: http://api.crossref.org/members/311/works?filter=type:journal-article&amp;rows=100&amp;cursor=*<br />
Second URL: http://api.crossref.org/members/311/works?filter=type:journal-article&amp;rows=100&amp;cursor=Aooo/MxxxxxxxxxxxtdA==<br />
Third URL: http://api.crossref.org/members/311/works?filter=type:journal-article&amp;rows=100&amp;cursor=Booo/MxxxxxxxxxxxtdA==<br />
&#8230;..<br />
&#8230;..</p>
<h2>Method-4: Pass Page Number in Body Attribute</h2>
<p>Some API allows you to pass your PageSize and Page number inside Request Body (i.e. POST data) in that case you may configure your options like below (We used Google AdWords Api as an example)</p>
<div id="attachment_10745" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10745" class="size-full wp-image-10745" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-pagination.png" alt="Method-4 Pass Page Number in Body Attribute" width="828" height="735" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-pagination.png 828w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-pagination-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-pagination-768x682.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10745" class="wp-caption-text">Configure REST API Pagination – using Page Number via POST Body Method</p></div>
<div id="attachment_10746" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-Settings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10746" class="size-full wp-image-10746" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-Settings.png" alt="Method-4: Pass Page Number in Body Attribute example" width="828" height="735" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-Settings.png 828w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-Settings-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-4-Settings-768x682.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10746" class="wp-caption-text">REST API Pagination – Passing PageNumber inside POST Body (Example: Google AdWords SOAP API)</p></div>
<h2>Method-5: REST API Pagination via multiple URL parameters (e.g. Start and End)</h2>
<p>In the previous section, you saw how to pass page numbers via URL (Single Parameter: http://abc.com/?page=1). However, sometimes you have a pagination requirement where you have to specify multiple parameters that need increment. See below example URL.</p><pre class="crayon-plain-tag">http://abc.com/?startRow=1&amp;endRow=100
http://abc.com/?startRow=101&amp;endRow=200
http://abc.com/?startRow=201&amp;endRow=300
...</pre><p>
<div id="attachment_10747" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-5-pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10747" class="size-full wp-image-10747" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-5-pagination.png" alt="Method-5: REST API Pagination via multiple URL parameters (e.g. Start and End)" width="828" height="478" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-5-pagination.png 828w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-5-pagination-300x173.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-5-pagination-768x443.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10747" class="wp-caption-text">Pagination via Multiple URL Parameters</p></div>
<h2>Method-6: REST API Pagination via Header (Next Link in Header)</h2>
<p>Another popular pagination method is paginate via Header. In this method, each API response includes special Header which indicates next link for your response. In header method there are two approaches. [1] Custom Method [2] RFC 5988 Method. Lets look at both.</p>
<h3>Next Link in Custom Header</h3>
<p>In this method you have to specify which response header contains next URL. When no more NEXT url found in response reader stops.</p>
<div id="attachment_10749" style="width: 650px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-REST-API-Pagination-via-Header.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10749" class="size-full wp-image-10749" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-REST-API-Pagination-via-Header.png" alt="Method 6 REST API Pagination via Headers" width="640" height="213" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-REST-API-Pagination-via-Header.png 640w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-REST-API-Pagination-via-Header-300x100.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></a><p id="caption-attachment-10749" class="wp-caption-text">Custom Header Pagination Method</p></div>
<h3>Next Link in Header as per RFC 5988</h3>
<p>In this method, HTTP response contains a special header (Link) which contains next link for our response. If no link found to read more data then reader stops. This method is described well here in <a href="https://tools.ietf.org/html/rfc5988" target="_blank" rel="noopener">RFC 5988</a>. Check this <a href="https://developer.github.com/v3/guides/traversing-with-pagination/" target="_blank" rel="noopener">GitHub API Example</a> to understand more on this pagination method.</p>
<div id="attachment_10751" style="width: 696px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Next-Link-in-Header-as-per-RFC-5988.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10751" class="size-full wp-image-10751" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Next-Link-in-Header-as-per-RFC-5988.png" alt="Method 6 Next Link in Header as per RFC 5988" width="686" height="144" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Next-Link-in-Header-as-per-RFC-5988.png 686w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Next-Link-in-Header-as-per-RFC-5988-300x63.png 300w" sizes="(max-width: 686px) 100vw, 686px" /></a><p id="caption-attachment-10751" class="wp-caption-text">Link Header Pagination Method (RFC 5988)</p></div>
<h2>Method-7: REST API Pagination using Cursor / Continuation Token from Response Header</h2>
<p>There will be a time when your API sends some sort of Continuation Token in Response Header and you have to use that token to call next request. Some API needs this token passed as query string in Next URL and in some API you have to pass as request header. We will cover both cases in the following section.</p>
<p>Your API might call these tokens as &#8220;Cursor&#8221; too so we will use these both terms in the following section (They both mean same thing).</p>
<p>There are few ways these APIs pass Cursor to the next request</p>
<ol>
<li>Pass Cursor via Request Header with <strong>same header name</strong></li>
<li>Pass Cursor via Request Header with <strong>different header name (introduced in v4.2.3)</strong></li>
<li>Pass multiple Response Headers via Request Headers (Azure DocumentDB style usecase)</li>
<li>Pass Cursor via URL Query String Parameter (<strong>introduced in v3.0 or later</strong>)</li>
</ol>
<p>Lets see all approaches.</p>
<h3>Pass Token via Request Header (Same header name)</h3>
<p>Consider the API pagination use case in which you get some sort of continuation token in the response header and you take it and pass in the next request via request header (same header name).</p>
<p>Example:</p>
<p><strong>First Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata

------- Response ------
x-token: Nxdfabcd11111

{ some response data }</pre><p>
<strong>Second Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata
x-token: Nxdfabcd11111

------- Response ------
x-token: Nxdfabcd22222

{ some response data }</pre><p>
&#8230;&#8230;</p>
<p>&#8230;&#8230;</p>
<p><strong>Last Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata
x-token: Nxdfabcd22222

------- Response ------

{ some response data }</pre><p>
For above pagination pattern  that just enter the response header name in <strong>Page Num Indicator</strong> field as below</p>
<div id="attachment_10752" style="width: 697px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-Token-via-Request-Header.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10752" class="size-full wp-image-10752" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-Token-via-Request-Header.png" alt="Method 7 Pass Token via Request Header" width="687" height="126" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-Token-via-Request-Header.png 687w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-Token-via-Request-Header-300x55.png 300w" sizes="(max-width: 687px) 100vw, 687px" /></a><p id="caption-attachment-10752" class="wp-caption-text">Pagination using response header continuation token – Pass as Request Header</p></div>
<p>All possible formats for Page Num Indicator is below</p>
<p>x-page-token<br />
x-token1, x-token2<br />
RequestUrlQueryName=ResponseHeaderName<br />
header::RequestHeaderName=ResponseHeaderName<br />
RequestUrlQueryName=ResponseHeaderName(regular-expression)</p>
<h3>Pass Token via Request Header (Different header name)</h3>
<p>Consider the API pagination use case just like previous one but only different is request header name is not same as response header name. For example rather than x-token in request we need to call it x-next-token.</p>
<p>Example:</p>
<p><strong>First Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata

------- Response ------
x-token: Nxdfabcd11111

{ some response data }</pre><p>
<strong>Second Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata
x-next-token: Nxdfabcd11111

------- Response ------
x-token: Nxdfabcd22222

{ some response data }</pre><p>
&#8230;&#8230;</p>
<p>&#8230;&#8230;</p>
<p><strong>Last Request / Response:</strong></p><pre class="crayon-plain-tag">------- Request ------
GET https://abc.com/api/getdata
x-next-token: Nxdfabcd22222

------- Response ------

{ some response data }</pre><p>
For above pagination pattern  that just enter the response header name in <strong>Page Num Indicator</strong> field as below</p>
<div id="attachment_10753" style="width: 702px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-Request-Header.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10753" class="size-full wp-image-10753" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-Request-Header.png" alt="Method 7 Pass Token via Request Header " width="692" height="197" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-Request-Header.png 692w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-Request-Header-300x85.png 300w" sizes="(max-width: 692px) 100vw, 692px" /></a><p id="caption-attachment-10753" class="wp-caption-text">Pagination using response header continuation token – Pass as Request Header (Different name)</p></div>
<h3>Pass multiple Response Headers via Request Headers (Azure DocumentDB style usecase)</h3>
<p>Some API like <a href="https://docs.microsoft.com/en-us/rest/api/cosmos-db/list-documents" target="_blank" rel="noopener">Azure Cosmos DB</a> uses Continuation Token via Header approach. In that case you can enter single header name or multiple headers like below (For multiple headers use comma)</p>
<div id="attachment_10754" style="width: 687px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-multiple-Response-Headers-via-Request-Headers-Azure-DocumentDB-style-usecase.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10754" class="size-full wp-image-10754" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-multiple-Response-Headers-via-Request-Headers-Azure-DocumentDB-style-usecase.png" alt="Method 7 Pass multiple Response Headers via Request Headers" width="677" height="207" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-multiple-Response-Headers-via-Request-Headers-Azure-DocumentDB-style-usecase.png 677w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Pass-multiple-Response-Headers-via-Request-Headers-Azure-DocumentDB-style-usecase-300x92.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a><p id="caption-attachment-10754" class="wp-caption-text">REST API Pagination using Continuation Token via Header (Azure CosmosDB / DocumentDB API Example )</p></div>
<p>You can use use tools <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">like Fiddler</a> to see paginated requests as below.</p>
<p><strong>First Request</strong></p>
<div id="attachment_10755" style="width: 953px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10755" class="size-full wp-image-10755" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-1.png" alt="Method 7 fiddler example 1" width="943" height="777" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-1.png 943w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-1-300x247.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-1-768x633.png 768w" sizes="(max-width: 943px) 100vw, 943px" /></a><p id="caption-attachment-10755" class="wp-caption-text">View Paginated Requests in Fiddler (Azure CosmosDB API Example)</p></div>
<p><strong>Second Request</strong></p>
<div id="attachment_10756" style="width: 1044px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10756" class="size-full wp-image-10756" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2.png" alt="Method 7 fiddler reuqest 2 " width="1034" height="785" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2.png 1034w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2-300x228.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2-768x583.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-Fiddler-2-1024x777.png 1024w" sizes="(max-width: 1034px) 100vw, 1034px" /></a><p id="caption-attachment-10756" class="wp-caption-text">Pass Next Page Token via Header (View Paginated Requests in Fiddler – Azure CosmosDB API Example)</p></div>
<h3>Pass Token via URL Parameter (Query String)</h3>
<p>In the new version we added a feature where you can actually read Continuation Token (i.e. Cursor) from Response Header and then pass to next request in the URL rather than Request Header. Here is the <a href="https://api.rosnet.com/#tag/Checks" target="_blank" rel="noopener">example API</a> which uses such method.</p>
<p><strong>First Request</strong></p><pre class="crayon-plain-tag">--------- Request ---------
GET
http://test.com/api/getdata

--------- Response ---------
X-RESPONSE-TOKEN : Pg2xxxxxxxxxxxxxxxxx

{ data : [ 1,2,3.... 10 ] }</pre><p>
<strong>Second Request </strong></p><pre class="crayon-plain-tag">--------- Request ---------
GET
http://test.com/api/getdata?cursor=Pg2xxxxxxxxxxxxxxxxx

--------- Response ---------
X-RESPONSE-TOKEN : Pg3xxxxxxxxxxxxxxxxx

{ data : [ 11,12,13.... 20 ] }</pre><p>
Here is how to configure above pagination pattern</p>
<div id="attachment_10759" style="width: 706px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-URL-Parameter.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10759" class="size-full wp-image-10759" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-URL-Parameter.png" alt="Method 7 Pass Token via URL Parameter (Query String)" width="696" height="148" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-URL-Parameter.png 696w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-6-Pass-Token-via-URL-Parameter-300x64.png 300w" sizes="(max-width: 696px) 100vw, 696px" /></a><p id="caption-attachment-10759" class="wp-caption-text">Pass Response Header value to URL (Cursor)</p></div>
<h3>Pass Token via URL Parameter (Query String) &#8211; with custom Regular expression (Usecase: Salesforce BULK query API)</h3>
<p>Now consider previous scenario but with slightly different requirement. By default previous pagination pattern stops when specified response header is missing or response header value is blank. However is some cases header value contains custom string to indicate last page. For example x-token: NULL. In such case we need to use <strong>Page Num Indicator</strong> like below (must use v4.2.3 or higher in SSIS PowerPack / 1.5.2 or higher in ODBC PowerPack)</p><pre class="crayon-plain-tag">nextUrlParameterName=responseHeadername(Some_Regular_Expression)</pre><p>
For example to stop pagination in below case you have to enter Page Num Indicator as below. It says stop pagination when  &#8220;NULL&#8221; word is detected</p><pre class="crayon-plain-tag">cursor=X-RESPONSE-TOKEN(^((?!NULL\b).)*$)</pre><p>
&nbsp;</p>
<p><strong>First Request</strong></p><pre class="crayon-plain-tag">--------- Request ---------
GET
http://test.com/api/getdata

--------- Response ---------
X-RESPONSE-TOKEN : Pg2xxxxxxxxxxxxxxxxx

{ data : [ 1,2,3.... 10 ] }</pre><p>
<strong>Second Request </strong></p><pre class="crayon-plain-tag">--------- Request ---------
GET
http://test.com/api/getdata?cursor=Pg2xxxxxxxxxxxxxxxxx

--------- Response ---------
X-RESPONSE-TOKEN : Pg3xxxxxxxxxxxxxxxxx

{ data : [ 11,12,13.... 20 ] }</pre><p>
&#8230;&#8230;</p>
<p>&#8230;&#8230;</p>
<p><strong>Last Request </strong></p><pre class="crayon-plain-tag">--------- Request ---------
GET
http://test.com/api/getdata?cursor=Pg3xxxxxxxxxxxxxxxxx

--------- Response ---------
X-RESPONSE-TOKEN : NULL

{ data : [ 21,22,23.... 30 ] }</pre><p>
Here is how to configure above pagination pattern</p>
<div id="attachment_10761" style="width: 706px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-with-custom-Regular-expression.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10761" class="size-full wp-image-10761" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-with-custom-Regular-expression.png" alt="Method 7 with custom Regular expression" width="696" height="156" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-with-custom-Regular-expression.png 696w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-7-with-custom-Regular-expression-300x67.png 300w" sizes="(max-width: 696px) 100vw, 696px" /></a><p id="caption-attachment-10761" class="wp-caption-text">Pass Response Header value to URL (Cursor)</p></div>
<h2>Method-8: Pass Pagination Token in Request Body</h2>
<p>In previous section (Method-4: Pass Page Number in Body Attribute ) we saw how to pass simple numeric page counter in Body. This is fine for some API but if your API has base64 style text token then counter based method doesn&#8217;t work. Also if you have requirement to hide page attribute node in first request and send page counter node in second request body (Changing Request Body Pattern for First vs Next)  then check next two sections.</p>
<p>Next two sections covers two API Pagination patterns to fetch 100 rows (1000 in each page) . Both requires to send token in Body but second section is more complex need (Different Body Attributes in first vs next requests )</p>
<h3>Passing Page Token in Body (Blank Token in first request allowed)</h3>
<p>Lets look at simple pattern where first request has blank token in Body but all other requests until we find last page we keep sending non-empty token. This approach works as long as API Provider doesn&#8217;t mind having Blank Token in first request. If you get error then check next section to handle more complex way.</p>
<p>Here is the example of API which needs token in body</p>
<p><strong>First API call</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdata

{ searchFor: "Account", continueToken:"" }

--------- Response ---------
{recordsFound: 5000, data: ["Acct1", "Acct2"..., "Acct1000"], nextToken:"AxBxCx112233001==" }</pre><p>
<strong>Second API call</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdata

{ searchFor: "Account", continueToken:"AxBxCx112233001==" }

--------- Response ---------
{data: ["Acct1001", "Acct1002"..., "Acct2000"], nextToken:"AxBxCx112233002==" }</pre><p>
&#8230;.. many more calls &#8230;</p>
<p>&#8230;. many more calls &#8230;.</p>
<p><strong>Last API call (no more nextToken in response so STOP pagination)</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdata

{ searchFor: "Account", continueToken:"AxBxCx112233009==" }

--------- Response ---------
{data: ["Acct9001", "Acct9002"..., "Acct10000"] }</pre><p>
So if you have such pattern then you can set few properties</p>
<p>For such issue you can use Changing few properties like below. Use Property Grid if you cant find on UI</p>
<ul>
<li>Set EnablePageTokenForBody  = <pre class="crayon-plain-tag">True</pre></li>
<li>Set PagePlaceholders = <pre class="crayon-plain-tag">header=|;filter=|;</pre></li>
<li>Set HttpRequestData = <pre class="crayon-plain-tag">{ searchFor: "Account", continueToken:"[$pagetoken$]" }</pre></li>
</ul>
<div id="attachment_10762" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10762" class="size-full wp-image-10762" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-1.png" alt="Method 8 Pass Passing Page Token in Body 1" width="828" height="488" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-1.png 828w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-1-300x177.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-1-768x453.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10762" class="wp-caption-text">Setting Body with [$pagetoken$] to implement dynamic pagination</p></div>
<div id="attachment_10763" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10763" class="size-full wp-image-10763" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2.png" alt="Method 8 advanced pagination tab" width="828" height="437" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2.png 828w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2-300x158.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2-768x405.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Pass-Passing-Page-Token-in-Body-2-720x380.png 720w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10763" class="wp-caption-text">Setting Page Placeholders in Advanced Pagination tab.</p></div>
<h3>Passing Page Token in Body (Blank Token in first request)</h3>
<p>Now let&#8217;s look at more complex pattern. Here our first request body is different than other requests.</p>
<p><strong>First API call</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdata

{ searchFor: "Account" }

--------- Response ---------
{recordsFound: 5000, data: ["Acct1", "Acct2"..., "Acct1000"], nextToken:"AxBxCx112233001==" }</pre><p>
<strong>Second API call</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdataNext

{ continueToken:"AxBxCx112233001==" }

--------- Response ---------
{data: ["Acct1001", "Acct1002"..., "Acct2000"], nextToken:"AxBxCx112233002==" }</pre><p>
&#8230;.. many more calls &#8230;</p>
<p>&#8230;. many more calls &#8230;.</p>
<p><strong>Last API call (no more nextToken)</strong></p><pre class="crayon-plain-tag">--------- Request ---------
POST http://test.com/api/getdataNext

{ continueToken:"AxBxCx112233009==" }

--------- Response ---------
{data: ["Acct9001", "Acct9002"..., "Acct10000"] }</pre><p>
So notice few things</p>
<ul>
<li>First Request Body / URL is different than second / third and Nth API call</li>
<li>For first request we do not have token attribute but after first request we do have token attribute</li>
</ul>
<p>We have <a href="https://zappysys.com/blog/call-amazon-mws-api-using-ssis-marketplace-web-service/" target="_blank" rel="noopener">this article</a> and <a href="https://zappysys.com/blog/read-data-netsuite-ssis-simpletalk-soap-api/" target="_blank" rel="noopener">this article</a> which describes similar pattern.</p>
<p>Now lets look at how to solve both problems</p>
<h3>Passing PageToken or Counter in Next API Call Body</h3>
<p>For such issue you can use Changing few properties like below. Use Property Grid if you cant find on UI</p>
<ul>
<li>Set EnablePageTokenForBody  = <pre class="crayon-plain-tag">True</pre></li>
<li>Set PagePlaceholders = <pre class="crayon-plain-tag">header=|;filter=|;</pre></li>
<li>Set HttpRequestData = <pre class="crayon-plain-tag">[$tag$]</pre></li>
<li>Set HasDifferentNextPageInfo = <pre class="crayon-plain-tag">True</pre></li>
<li>Set FirstPageBodyPart = <pre class="crayon-plain-tag">{ searchFor: "Account"}</pre></li>
<li>Set NextPageBodyPart = <pre class="crayon-plain-tag">{ token:"[$pagetoken$]" }</pre></li>
</ul>
<p>So notice how we defined Body in two different properies as template. And in HttpRequestData we used <pre class="crayon-plain-tag">[$tag$]</pre>
<h2>Output Page Number as column</h2>
<p>Sometimes you have use case where you want to Start Page Number from the last page loaded successfully. By default, you will see one additional column __FileName in the output. This column contains PageNumber  from URL for each row. You can save this into database so when next time you run your SSIS you can start at MAX(PageNumber) + 1.</p>
<p>Outputting PageNumber option is not visible by default so Use Property Grid and look for <strong>OutputFileName</strong> property (Default=true)</p>
<h2>Last Page Detection</h2>
<p>Every API may have different way of telling you that you reached last page or no more data found so you should stop looping. SSIS PowerPack comes with many options so you can implement desired logic for last page detection.</p>
<p>Following approaches supported by last page detection. Below options are not applicable if you are using Method#3 (Response contains Next Link / Cursor)</p>
<ol>
<li>Detect the last page by row count</li>
<li>Detect the last page by response status code</li>
<li>Detect the last page by error message (substring search)</li>
<li>Detect the last page by response size</li>
<li>Detect the last page based on response value or regular expression pattern</li>
</ol>
<p>Now lets look at each setting. You should choose correct one based on your API behavior</p>
<h3>Detect the last page by row count</h3>
<p>If your API returns blank document or blank Array (if its JSON) then you can use this method to detect the last page. So when no content found in Response document it will stop pagination.</p>
<p>See below example of JSON API .. It shows sample first page and Sample last page (Assuming you entered Filter as $.Records[*] to extract data from Records array.</p>
<p><strong>First Page</strong></p><pre class="crayon-plain-tag">{&nbsp;
&nbsp; Records : [ {...}, {...}, {...} .........&nbsp;]
}</pre><p>
<strong>Last Page</strong></p><pre class="crayon-plain-tag">{&nbsp;
&nbsp; Records : [&nbsp;&nbsp;]
}</pre><p>
<div id="attachment_10769" style="width: 654px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-row-count.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10769" class="size-full wp-image-10769" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-row-count.png" alt="Method 8 Detect the last page by row count" width="644" height="222" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-row-count.png 644w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-row-count-300x103.png 300w" sizes="(max-width: 644px) 100vw, 644px" /></a><p id="caption-attachment-10769" class="wp-caption-text">SSIS API Pagination – Detect the last page by row count (Blank document or array)</p></div>
<h3>Detect the last page by response status code</h3>
<p>Sometimes you get error with status code when the last page is reached (Most common is 404). So rather than failure, you can treat that status code as last page indicator using this option (see below).</p>
<div id="attachment_10766" style="width: 644px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-status-code.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10766" class="size-full wp-image-10766" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-status-code.png" alt="Method 8 Detect the last page by response status code" width="634" height="245" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-status-code.png 634w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-status-code-300x116.png 300w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-10766" class="wp-caption-text">SSIS API Pagination – Detect last page by response status code</p></div>
<h3>Detect the last page by the error message</h3>
<p>If you cant use above two methods and want to detect the last page based on a certain error string in the response then use below approach.</p>
<div id="attachment_10767" style="width: 647px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-the-error-message.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10767" class="size-full wp-image-10767" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-the-error-message.png" alt="Method 8 Detect the last page by the error message" width="637" height="249" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-the-error-message.png 637w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-the-error-message-300x117.png 300w" sizes="(max-width: 637px) 100vw, 637px" /></a><p id="caption-attachment-10767" class="wp-caption-text">SSIS API Pagination – Detect the last page by error/response string search</p></div>
<h3>Detect the last page by response size</h3>
<p>Sometimes you can detect the last page by response size. For example, your response contains &#8220;&#8211;&#8221; only if no more data is found then you cannot use any of the above approaches and you have to detect based on response size (e.g. less than 3 bytes). See below</p>
<div id="attachment_10768" style="width: 654px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-size-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10768" class="size-full wp-image-10768" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-size-1.png" alt="Method 8 Detect the last page by response size" width="644" height="243" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-size-1.png 644w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-by-response-size-1-300x113.png 300w" sizes="(max-width: 644px) 100vw, 644px" /></a><p id="caption-attachment-10768" class="wp-caption-text">SSIS API Pagination – Detect last page by response size</p></div>
<h3>Detect the last page based on the response attribute value</h3>
<p>There will be a time when you want to detect the last page based on some indicator value from your response. In that case, you can use the following settings to detect the last page.</p>
<ul>
<li>Select Paging mode =Response Attribute Mode</li>
<li>Select Next Link Attribute (Example: <strong>$.next_page</strong> )</li>
<li>Select Stop Indicator Attribute (Example: <strong>$.hasMorePages</strong> )</li>
<li>Enter a value for Stop Indicator (Example: <strong>false</strong> )</li>
</ul>
<p>If you don&#8217;t want to use Hardcoded value for stop indicator and want to use expression then see next section.</p>
<h3>Detect the last page based on regular expression pattern</h3>
<p>There will be a time when you want to detect the last page based on some indicator value from your response. In that case, you can use the following settings to detect the last page.</p>
<ul>
<li>Select Paging mode =Response Attribute Mode</li>
<li>Select Next Link Attribute (Example: <strong>$.next_page</strong> )</li>
<li>Select Stop Indicator Attribute (Example: <strong>$.count</strong> )</li>
<li>Enter regex pattern (regular expression) for Stop Indicator (Example: <strong>regex=^\d{1,3}$</strong> ). Stop when count attribute is less than 1000 in other word less than 4 digits.</li>
</ul>
<p>Here is an example from <a href="https://zappysys.com/blog/read-zendesk-data-in-ssis-call-rest-api/" target="_blank" rel="noopener">Zendesk API</a> (Stop pagination when count attribute from the response is less than 1000)</p>
<div id="attachment_10770" style="width: 687px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-based-on-regular-expression-pattern.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10770" class="size-full wp-image-10770" src="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-based-on-regular-expression-pattern.png" alt="Method 8 Detect the last page based on regular expression pattern" width="677" height="418" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-based-on-regular-expression-pattern.png 677w, https://zappysys.com/blog/wp-content/uploads/2016/04/Method-8-Detect-the-last-page-based-on-regular-expression-pattern-300x185.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a><p id="caption-attachment-10770" class="wp-caption-text">Pagination for Zendesk Incremental API – Next Link and Last Page detection using Stop Indicator Regular Expression</p></div>
<div class="content_block" id="custom_post_widget-9862"><h2>Handling API Rate Limit - Retry on too many API requests</h2>
<p>Many API restricts you from calling too many API calls too soon (just to save their servers from being overwhelmed) - <a href="https://shopify.dev/api/usage/rate-limits" target="_blank" rel="noopener">Example</a>. Let's think this way if you fetching a million rows via paginated response and the very last page fails then you won't be happy because now you have to fetch everything again. To solve this ZappySys provides retry options on HTTP / OAuth and REST API connection managers.</p>

<p>Generally, when you exceed the rate limit, the server sends you <strong>error code 429</strong> but it can be something else too or multiple codes are returned. In the below example, we use 503. Check your API documentation to know the exact code you should retry.</p>

<p>To set the retry options go to connection settings (e.g. HTTP / OAuth / REST connection). The below example is for OAuth connection.</p>

<p>To retry on multiple codes use Pipe as a delimiter. Example: <strong>429|503</strong></p>


<div class="wp-caption alignnone">
 <a href="https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection.png">
   <img decoding="async" src="https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection.png" alt="Retry Settings for API Rate Limit Exceeded Error (Status code 429)" />
 </a>
<p class="wp-caption-text">Retry Settings for API Rate Limit Exceeded Error (Status code 429 or other)</p>
</div></div>
<h2>Performance Tips</h2>
<p>You can improve performance of your API calls by doing a few changes (again not every API may support this)</p>
<ul>
<li>Use the maximum page size possible (e.g. if you doing pagination you can set max possible page size &#8211; refer to your API documentation whats the default size and what is the max page size you can supply)<br />
e.g.  /myapi?pagesize=100  (parameter name can be something else like limit=100)</li>
</ul>
<p>&nbsp;</p>
<h2>SSIS Infinite Loop</h2>
<p>So now you know how to paginate automatically in <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON Source Connector</a> but what if you want to use <a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/">REST API Task</a> for pagination? Some custom scenarios like web scraping require you to download all HTML pages until no more results found? In that case, you most likely need infinite looping pattern (Loop until the last page detected). To loop through pages until the last page is reached you can perform the following logic.</p>
<p>The last page can be detected based on any of the following ways<br />
1. Check Response StatusCode<br />
2. Check Error Message<br />
3. Check Response Size (If less than X bytes then consider as the last page)</p>
<p>REST API Task support #1 and #2 scenarios. If you want to check bytes then use the expression in Expression Task or Script Task<br />
(e.g. @exitloop = LEN(@responseData) &lt;= 3 )</p>
<p><b>URL for Rest API Task (On Request Settings Tab)</b><br />
When you configure REST API Task enter URL as below so its dynamic. You can use PageCounter variable anywhere in the URL.</p><pre class="crayon-plain-tag">//zappysys.com/downloads/files/test/cust-{{User::pagecounter}}.json</pre><p>
<div id="attachment_10771" style="width: 755px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10771" class="size-full wp-image-10771" src="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-1.png" alt="SSIS Infinite Loop part 1 " width="745" height="957" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-1.png 745w, https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-1-234x300.png 234w" sizes="(max-width: 745px) 100vw, 745px" /></a><p id="caption-attachment-10771" class="wp-caption-text">SSIS REST API Looping – Pass Page number in URL, SSIS Infinite Loop</p></div>
<div id="attachment_10772" style="width: 729px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10772" class="size-full wp-image-10772" src="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-2.png" alt="SSIS Infinite Loop part 2" width="719" height="504" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-2.png 719w, https://zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Infinite-Loop-2-300x210.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></a><p id="caption-attachment-10772" class="wp-caption-text">Configure For Loop Task for Infinite Looping (Loop until last page found)</p></div>
<h2>Download Sample SSIS Package</h2>
<p><a href="//zappysys.com/blog/wp-content/uploads/2016/04/SSIS-Loop-Rest-API-2012.dtsx.zip">SSIS-Loop-Rest-API-2012.dtsx (Zip file)</a></p>
<h2>Video Tutorial &#8211; Reading data from API in SSIS</h2>
<p>In case you missed our previous article about <a href="https://zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">calling REST API is SSIS</a> then check below video.</p>
<a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/"><img decoding="async" src="https://zappysys.com/blog/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FaO8cVRyCBWw%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>It can be time consuming and steep learning curve to write C#/JAVA code to handle your rest api integration but using some Tasks and Connectors listed below can help you to solve big headache and provide clean drag and drop REST API integration in SSIS for virtually any REST API Source (e.g. Twitter, Facebook, Salesforce, office 365). <a href="//zappysys.com/products/ssis-powerpack/">Download SSIS PowerPack</a> and try it out by yourself.</p>
<h2 class="su-box-title">SSIS Components for REST API/JSON/XML/SOAP</h2>
<div class="su-box-content su-clearfix">
<table>
<tbody>
<tr>
<td width="36"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/SSIS-Json-Source-Adapter.png" alt="Custom SSIS Components - JSON Source (File and REST API Connector)" width="32" /></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">JSON Source Connector (File, REST API)</span></a></td>
</tr>
<tr>
<td width="36"><span style="color: #248cc8;"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-export-json-file-task.png" alt="Custom SSIS Tasks - Export JSON File Task" width="32" /></span></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-export-json-file-task/" target="_blank" rel="noopener"><span style="color: #248cc8;">Export JSON File Task</span></a></td>
</tr>
<tr>
<td width="36"><span style="color: #248cc8;"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-json-parser-task.png" alt="Custom SSIS Tasks - JSON Parser Task" width="32" /></span></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-task-free/" target="_blank" rel="noopener"><span style="color: #248cc8;">JSON Parser Task</span></a></td>
</tr>
<tr>
<td width="36"><span style="color: #248cc8;"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-xml-source.png" alt="Custom SSIS Tasks - XML Source Connector (File, SOAP, REST API)" width="32" /></span></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8;">XML Source Connector (File, SOAP, REST API)</span></a></td>
</tr>
</tbody>
</table>
</div>
<p>The post <a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/">How to do REST API Pagination in SSIS / ODBC Drivers</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How to read Zendesk data in SSIS with REST API</title>
		<link>https://zappysys.com/blog/read-zendesk-data-in-ssis-call-rest-api/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 27 Oct 2015 20:18:41 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[api pagination]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[zendesk]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=132</guid>

					<description><![CDATA[<p>Introduction Zendesk is one of the most popular customer service platforms available today. Zendesk offers a REST API to interact with its cloud-based service programmatically (to manage or read data). The problem is that not everyone is a programmer, and not everyone has time to learn how to write C# or JAVA code to access a [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/read-zendesk-data-in-ssis-call-rest-api/">How to read Zendesk data in SSIS with REST API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>UPDATE:</strong> ZappySys has released a brand new <a target="_blank" rel="noopener">Zendesk Online connector,</a> which makes it much simpler to <strong>read/write Zendesk Data in SSIS</strong> compared to the steps listed in this article. You can still use the steps from this article, but if you are new to APIs or want to avoid the learning curve, use a newer approach.</p>
</div></div>
<p><a href="//zappysys.com/blog/wp-content/uploads/2015/10/zendesk-api-integration.png"><img loading="lazy" decoding="async" class=" wp-image-1628 alignleft" src="//zappysys.com/blog/wp-content/uploads/2015/10/zendesk-api-integration.png" alt="" width="126" height="126" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/zendesk-api-integration.png 200w, https://zappysys.com/blog/wp-content/uploads/2015/10/zendesk-api-integration-150x150.png 150w" sizes="(max-width: 126px) 100vw, 126px" /></a><a href="http://zendesk.com">Zendesk</a> is one of the most popular customer service platforms available today. <span style="box-sizing: border-box; margin: 0px; padding: 0px;"><a href="https://developer.zendesk.com/rest_api/docs/support/introduction" target="_blank" rel="noopener">Zendesk offers a REST API</a> to interact with its cloud-based service programmatically (to manage or read data).</span> The problem is that not everyone is a programmer, and not everyone has time to learn how to write C# or JAVA code to access a REST API.</p>
<p>In this article, you will learn how to get Zendesk data using the <a target="_blank" rel="noopener">SSIS JSON Source (REST API Connector).</a> This connector allows you to read Zendesk data in SSIS using REST API Calls without any scripting/programming. <span style="box-sizing: border-box; margin: 0px; padding: 0px;">Techniques mentioned in this article can also be used to consume data from other services (e.g., <a target="_blank" rel="noopener">read data from Twitter</a>).</span> In this article, you will see step-by-step instructions to read Zendesk ticket information and load it into on-premises SQL Server.</p>
<p>Also, check our other article <span style="box-sizing: border-box; margin: 0px; padding: 0px;">on <a target="_blank" rel="noopener">how</a></span><a href="//zappysys.com/blog/call-zendesk-rest-api-ssis-create-new-ticket/" target="_blank" rel="noopener"> to call the Zendesk REST API to create a new ticket</a>.</p>
<h2>Different methods for Zendesk REST API Access</h2>
<p>Zendesk allows you to access its data in three different ways.</p>
<ol>
<li>REST API access using OAuth Access Token</li>
<li>REST API access using API Token</li>
<li>REST API access using Basic Authentication (Use userid (e.g., email) and Password)</li>
</ol>
<p>Each method has pros and cons. The simplest method is the third, which is easy to use but requires passing your account password with each call. The second method is also easy to use but requires an additional step to create an access token. The first method is the most secure, but it has a few extra steps compared to the other methods.</p>
<h2><span id="Prerequisite">Prerequisite</span></h2>
<p>Before you can finish the tasks explained in this article, you have to finish the following steps. This article assumes you have basic knowledge of SSIS (SQL Server Integration Services)</p>
<ol>
<li>Make sure you have the SSIS designer installed. Sometimes it&#8217;s referred to as BIDS or SSDT (<a href="https://msdn.microsoft.com/en-us/mt186501" target="_blank" rel="noopener">Get from here)</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">Download SSIS PowerPack</a> (FREE Trial &#8211; 30 days).</li>
<li>Optional – Another very useful Free tool is Fiddler. You can use it to see raw request/response (<a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Check this article</a>)</li>
</ol>
<h2>Method-1: Zendesk API Access using OAuth in SSIS</h2>
<p>To read about the OAuth Method, <a href="https://zappysys.com/blog/configure-zendesk-oauth-application-for-rest-api-call/" target="_blank" rel="noopener">click here</a></p>
<h2>Method-2: Zendesk API Access using Token in SSIS</h2>
<p>Now let&#8217;s look at the second method for accessing Zendesk data using SSIS.</p>
<h3>Create Token in Zendesk Portal for REST API Access</h3>
<ol>
<li>Log in to your account https://{{your-subdomain}}.zendesk.com/login and then click on the settings icon</li>
<li>On the next page, click on the API link</li>
<li>On the API page, scroll to the API Access Tokens section. Make sure the <strong>Token Access</strong> method is checked.</li>
<li>Click on the &#8221; add new token hyperlink. Once prompted, give a name to the Token token (this is just a label)</li>
<li>Once the above steps are done, a token should be created and listed under your API Access page. The token will be used as your Password to access the REST API (will be shown in the next section). For more information, check this link &gt;&gt;&gt;  <a href="https://support.zendesk.com/hc/en-us/articles/226022787-Generating-a-new-API-token-" target="_blank" rel="noopener">How to generate a token for ZenDesk API Call</a>.
<div id="attachment_11852" style="width: 993px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Create-new-Zendesk-REST-API-Access-Token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11852" class="size-full wp-image-11852" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Create-new-Zendesk-REST-API-Access-Token.png" alt="" width="983" height="701" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Create-new-Zendesk-REST-API-Access-Token.png 983w, https://zappysys.com/blog/wp-content/uploads/2015/10/Create-new-Zendesk-REST-API-Access-Token-300x214.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/Create-new-Zendesk-REST-API-Access-Token-768x548.png 768w" sizes="(max-width: 983px) 100vw, 983px" /></a><p id="caption-attachment-11852" class="wp-caption-text">Create a new Zendesk REST API Access Token</p></div></li>
</ol>
<h3>Configure SSIS HTTP Connection</h3>
<p>Perform the following steps to extract data from Zendesk and load it into SQL Server. The steps below assume that you are using the API Token method (#2 from the supported methods to call the Zendesk API). This is better than using Userid and Password.</p>
<ol>
<li>Open a new SSIS Project.</li>
<li>First of all, drag and drop the Data Flow Task from the SSIS Toolbox and double-click it to edit.
<div class="mceTemp"></div>
<div id="attachment_11784" style="width: 485px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2026/02/Drag-and-drop-Data-flow.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11784" class="size-full wp-image-11784" src="https://zappysys.com/blog/wp-content/uploads/2026/02/Drag-and-drop-Data-flow.png" alt="" width="475" height="178" srcset="https://zappysys.com/blog/wp-content/uploads/2026/02/Drag-and-drop-Data-flow.png 475w, https://zappysys.com/blog/wp-content/uploads/2026/02/Drag-and-drop-Data-flow-300x112.png 300w" sizes="(max-width: 475px) 100vw, 475px" /></a><p id="caption-attachment-11784" class="wp-caption-text">Drag and drop Data flow.w</p></div></li>
<li>From the SSIS toolbox, drag and drop the <a target="_blank" rel="noopener">ZS JSON Source</a> onto the data flow designer surface, then double-click it to edit.
<div id="attachment_11533" style="width: 553px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/09/ssis-json-source-adapter-drag.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11533" class="size-full wp-image-11533" src="https://zappysys.com/blog/wp-content/uploads/2015/09/ssis-json-source-adapter-drag.png" alt="" width="543" height="146" srcset="https://zappysys.com/blog/wp-content/uploads/2015/09/ssis-json-source-adapter-drag.png 543w, https://zappysys.com/blog/wp-content/uploads/2015/09/ssis-json-source-adapter-drag-300x81.png 300w" sizes="(max-width: 543px) 100vw, 543px" /></a><p id="caption-attachment-11533" class="wp-caption-text">SSIS JSON Source &#8211; Drag and Drop</p></div>
<div class="mceTemp"></div>
</li>
<li>From the AccessMode dropdown [<strong>Url From Connection</strong>]</li>
<li>Assume you want to extract all tickets from Zendesk, then enter the following URL (in the screenshot, we appended?page=1, which is optional)<br />
<pre class="crayon-plain-tag">https://YOUR_SUB_DOMAIN.zendesk.com/api/v2/tickets.json</pre>
</li>
<li>Check the <strong>Use Credentials</strong> option and select New ZS-HTTP connection. When prompted<br />
For Credential Type: select <strong>Basic Authentication</strong>  (Use of UserID and Token ).<br />
For Web URL: Enter any URL (This will be ignored anyway because the URL entered on the JSON Source UI will be used)<br />
For user name : enter <strong>YOUR_EMAIL/token  (e.g. bob@mycompany.com/token)<br />
</strong>For Password: enteToken token obtained from the Admin console &gt; API section. For more information, check this link &gt;&gt;&gt;  <a href="https://support.zendesk.com/hc/en-us/articles/226022787-Generating-a-new-API-token-" target="_blank" rel="noopener">How to generate a token for ZenDesk API Call</a>.<br />
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Appending /token command in Userid will allow us to pass the token rather than the Password of that account. This approach is more secure because you can disable the Token at any time without deactivating the user account. If you want to access data using your userid and Password rather than a token, then do not use <strong>/token</strong> after your email. By default, uToken Token and the use of Password are not allowed unless you enable these methods from the Admin console (See above section)</div></div>
<div class="mceTemp"></div>
<div id="attachment_11844" style="width: 838px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Configure-SSIS-HTTP-Connection-Use-Zendesk-Token-to-Call-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11844" class="size-full wp-image-11844" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Configure-SSIS-HTTP-Connection-Use-Zendesk-Token-to-Call-REST-API.png" alt="" width="828" height="745" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Configure-SSIS-HTTP-Connection-Use-Zendesk-Token-to-Call-REST-API.png 828w, https://zappysys.com/blog/wp-content/uploads/2015/10/Configure-SSIS-HTTP-Connection-Use-Zendesk-Token-to-Call-REST-API-300x270.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/Configure-SSIS-HTTP-Connection-Use-Zendesk-Token-to-Call-REST-API-768x691.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-11844" class="wp-caption-text">Configure SSIS HTTP Connection &#8211; Use Zendesk Token to Call REST API</p></div></li>
</ol>
<h3>Adding Retry Settings for HTTP or OAuth connection</h3>
<p>Zendesk enforces an API rate limit, which means you cannot issue too many API calls within a given time frame. <a href="https://developer.zendesk.com/rest_api/docs/support/introduction#rate-limits" target="_blank" rel="noopener">Check this document</a> for exact information.</p>
<p>ZappySys provides API retry settings on both the OAuth Connection and the HTTP Connection. For Zendesk, you can retry on a specific status code <strong>429</strong></p>
<ol>
<li>Open connection manager UI</li>
<li>Go to the Retry-Settings page</li>
<li>Select <strong>Retry web error on matching response status code</strong>.</li>
<li>Enter <strong>429</strong> for the status code</li>
<li>Check <strong>multiple wait times</strong></li>
<li>In the wait time, enter <strong>5000</strong> (wait 5 seconds or multiple of 5 seconds)</li>
<li>Set the max retry count to <strong>6. </strong>See the example (It&#8217;s not for Zendesk, but will give you an idea)
<div id="attachment_11847" style="width: 667px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/OAuth-connection-Retry-Options.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11847" class="size-full wp-image-11847" src="https://zappysys.com/blog/wp-content/uploads/2015/10/OAuth-connection-Retry-Options.png" alt="" width="657" height="604" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/OAuth-connection-Retry-Options.png 657w, https://zappysys.com/blog/wp-content/uploads/2015/10/OAuth-connection-Retry-Options-300x276.png 300w" sizes="(max-width: 657px) 100vw, 657px" /></a><p id="caption-attachment-11847" class="wp-caption-text">OAuth connection &#8211; Retry Options</p></div></li>
</ol>
<h3>Configure Zendesk API Pagination and Filter for SSIS JSON Source</h3>
<ol>
<li>Now click [Select Filter], select the tickets node (see the array icon), and click OK. It will generate the following Filter Expression to extract all records found under the tickets array node (e.g., tickets : [ {&#8230;} , {&#8230;} &#8230; ] )<br />
<pre class="crayon-plain-tag">$.tickets[*]</pre>
<div class="mceTemp"></div>
<div id="attachment_11853" style="width: 838px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Select-Filter-Extract-Data-from-Zendesk-API-Response-Read-Ticket.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11853" class="size-full wp-image-11853" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Select-Filter-Extract-Data-from-Zendesk-API-Response-Read-Ticket.png" alt="" width="828" height="745" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Select-Filter-Extract-Data-from-Zendesk-API-Response-Read-Ticket.png 828w, https://zappysys.com/blog/wp-content/uploads/2015/10/Select-Filter-Extract-Data-from-Zendesk-API-Response-Read-Ticket-300x270.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/Select-Filter-Extract-Data-from-Zendesk-API-Response-Read-Ticket-768x691.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-11853" class="wp-caption-text">Select Filter &#8211; Extract Data from Zendesk API Response (Read Ticket)</p></div></li>
<li>N, let&#8217;sts configure pagination. By default, Zendesk API doesn&#8217;t return all records, so you have to specify pagination as below. Click on the <strong>Pagination</strong> Tab. Enter <em>$.next_page</em> for Next URL attribute as below (you can also Browse Path)
<div id="attachment_11854" style="width: 841px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Zendesk-Pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11854" class="size-full wp-image-11854" src="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Zendesk-Pagination.png" alt="" width="831" height="747" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Zendesk-Pagination.png 831w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Zendesk-Pagination-300x270.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Zendesk-Pagination-768x690.png 768w" sizes="(max-width: 831px) 100vw, 831px" /></a><p id="caption-attachment-11854" class="wp-caption-text">SSIS JSON Source Zendesk Pagination</p></div></li>
<li>Now time to click <strong>Preview. </strong>If you followed everything correctly, then when you click the <strong>Preview</strong> Button, you should see some data in the preview (assuming you have at least one ticket).
<div class="mceTemp"></div>
<div id="attachment_11850" style="width: 840px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Data-Preview-Zendesk-REST-API-Call-to-extract-tickets.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11850" class="size-full wp-image-11850" src="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Data-Preview-Zendesk-REST-API-Call-to-extract-tickets.png" alt="" width="830" height="747" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Data-Preview-Zendesk-REST-API-Call-to-extract-tickets.png 830w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Data-Preview-Zendesk-REST-API-Call-to-extract-tickets-300x270.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-JSON-Source-Data-Preview-Zendesk-REST-API-Call-to-extract-tickets-768x691.png 768w" sizes="(max-width: 830px) 100vw, 830px" /></a><p id="caption-attachment-11850" class="wp-caption-text">SSIS JSON Source &#8211; Data Preview &#8211; Zendesk REST API Call to extract tickets</p></div></li>
<li>Now click the <strong>Columns tab</strong> to review data types (you can change the default length and check the Lock option on the right side). This change is needed because the datatype guess happens based on the design-time setting (only 300 rows scanned by default). At runtime, if you get a truncation-related error, then copy the error message into Notepad to get the exact steps and column name that caused the error. If you need a length greater than 4000 chars, use the DT_NTEXT data type instead (change the datatype and click the column name cell on the right to save the change).</li>
<li>Click <strong>OK</strong> to save UI</li>
</ol>
<h3>How to extract Zendesk data using Incremental API</h3>
<p>There will be a time when you need to extract data incrementally (i.e., Extract only the changed data since the last load). Zendesk API supports many <a href="https://developer.zendesk.com/rest_api/docs/support/incremental_export" target="_blank" rel="noopener">Incremental API endpoints</a>. If you are using this endpoint, you have to make sure of a few things.</p>
<ul>
<li>For the OAuth connection method, make sure the <pre class="crayon-plain-tag">read</pre>  scope is included ( <pre class="crayon-plain-tag">tickets:read</pre>  won&#8217;t work, so just use <pre class="crayon-plain-tag">read</pre> )</li>
<li>Your URL must include /incremental path before the API type, and you must include start_time for the extract in <a href="https://www.epochconverter.com/" target="_blank" rel="noopener">Unix Epoch Format</a>.  The following example will pull records modified after<br />
<pre class="crayon-plain-tag">https://zappysys.zendesk.com/api/v2/incremental/tickets.json?start_time=1514764800</pre>
</li>
<li>On the pagination tab, you have to configure the following settings
<ul>
<li>Set Next Link as <pre class="crayon-plain-tag">$.next_link</pre></li>
<li>Set the Stop Indicator attribute as <pre class="crayon-plain-tag">$.count</pre></li>
<li>Set the Stop Indicator Value as <pre class="crayon-plain-tag">regex=^\d{1,3}$</pre>  Notice that using <strong>regex=</strong> prefix treats your end indicator value as a pattern check.<strong>&#8212;OR&#8212;</strong></li>
<li>Set the Stop Indicator attribute as <pre class="crayon-plain-tag">$.end_of_stream</pre>   and the Stop indicator value as <pre class="crayon-plain-tag"><span class="lang:default decode:true crayon-inline ">true</pre></span>
<div id="attachment_11848" style="width: 838px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Pagination-for-Zendesk-Incremental-API-Next-Link-and-Last-Page-detection-using-Stop-Indicator-Regular-Expression.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11848" class="size-full wp-image-11848" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Pagination-for-Zendesk-Incremental-API-Next-Link-and-Last-Page-detection-using-Stop-Indicator-Regular-Expression.png" alt="" width="828" height="745" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Pagination-for-Zendesk-Incremental-API-Next-Link-and-Last-Page-detection-using-Stop-Indicator-Regular-Expression.png 828w, https://zappysys.com/blog/wp-content/uploads/2015/10/Pagination-for-Zendesk-Incremental-API-Next-Link-and-Last-Page-detection-using-Stop-Indicator-Regular-Expression-300x270.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/Pagination-for-Zendesk-Incremental-API-Next-Link-and-Last-Page-detection-using-Stop-Indicator-Regular-Expression-768x691.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-11848" class="wp-caption-text">Pagination for Zendesk Incremental API &#8211; Next Link and Last Page detection using Stop Indicator Regular Expression</p></div></li>
</ul>
</li>
</ul>
<p>Here is a simple SQL query to convert date/time to Unix time</p><pre class="crayon-plain-tag">select DATEDIFF(SECOND,'1970-01-01', GETUTCDATE() )

select DATEDIFF(SECOND,'1970-01-01', LastExtractDate ) as LastExtractDateAsUnix From dbo.ExtractStatus Where ExtractName='ZendeskExtract'</pre><p>
For C# code in the SSIS Script Task, you can use something like the following:</p><pre class="crayon-plain-tag">Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;</pre><p>
Assuming you extracted Date/Time from the database and saved it to some SSIS Variable called User::varLastExtract. Now we like to convert that to Unix format using C#.</p>
<p>We assume you have created the following variables in the SSIS Package. Also, you have set varLastExtract to a date/time value you want to convert.</p><pre class="crayon-plain-tag">User::varLastExtractTimeUnix  (Int32)
User::varLastExtractTime (DateTime)</pre><p>
Use the steps below. to convert date time to Unix format in C#</p>
<ol>
<li>Drag and drop Script Task in SSIS designer</li>
<li>Add both variable names in Read/Write Variable List (e.g., User::varLastExtractTimeUnix, User::varLastTimeExtract ).</li>
<li>Edit Script</li>
<li>Enter something like below<br />
<pre class="crayon-plain-tag">DateTime dtUtc= Convert.ToDateTime( Dts.Variables["User::varLastExtractTime"].Value ).ToUniversalTime();
Dts.Variables["User::varLastExtractTimeUnix"].Value = (Int32)(dtUtc.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;</pre>
</li>
</ol>
<p>Now you can use this variable in your JSON Source URL to make things dynamic.</p><pre class="crayon-plain-tag">https://zappysys.zendesk.com/api/v2/incremental/tickets.json?start_time={{User::varLastExtractTimeUnix}}</pre><p>
<h3>Handling duplicate data during incremental load (DISTINCT)</h3>
<p>As per <a href="https://developer.zendesk.com/rest_api/docs/support/incremental_export#excluding-pagination-duplicates" target="_blank" rel="noopener">this Zendesk document,</a> they may include the last row of the previous page on the next page if the update timestamp. It is possible to have duplicate rows in your staging table. <span style="box-sizing: border-box; margin: 0px; padding: 0px;">You can easily avoid this by using the <strong>DISTINCT</strong> keyword or another SQL query to remove duplicates.</span> Make sure not to include <strong>P_next_page</strong> and <strong>P_count,</strong> as they can differ when duplicate rows are detected at page boundaries.</p><pre class="crayon-plain-tag">SELECT DISTINCT 
--[P_next_page] --- Do NOT include this... 
[P_previous_page]
--,[P_count] --- Do NOT include this... 
,[url]
,[id]
,[external_id]
,[via.channel]
,[via.source.rel]

,[assignee_id]
......
......
......
,[allow_attachments]
FROM [dbo]._stgZendeskTickets</pre><p>
&nbsp;</p>
<h3>Loading data from Zendesk to SQL Server using SSIS</h3>
<ol>
<li>Now, drag a new OLE DB Destination into the Data Flow Designer. Connect the JSON source with the destination. Now double-click Destination. At the destination, select connection manager (or create one), then click [New] next to the Table name dropdown. You will see default metadata for the table based on upstream columns. Notice how P_previous_link is 40 chars rather than 140. This can be edited in the source metadata under the Columns tab, as described in the previous step, so that Table datatypes are set correctly. Once you change the table name and datatypes, click OK to create the new table. Click on the <strong>Mapping</strong> Tab to map source columns to target columns. Once that&#8217;s done, click OK to save.
<div id="attachment_11846" style="width: 763px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Load-Zendesk-Data-into-SQL-Server-Using-SSIS-JSON-Connector-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11846" class="size-full wp-image-11846" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Load-Zendesk-Data-into-SQL-Server-Using-SSIS-JSON-Connector-REST-API.png" alt="" width="753" height="684" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Load-Zendesk-Data-into-SQL-Server-Using-SSIS-JSON-Connector-REST-API.png 753w, https://zappysys.com/blog/wp-content/uploads/2015/10/Load-Zendesk-Data-into-SQL-Server-Using-SSIS-JSON-Connector-REST-API-300x273.png 300w" sizes="(max-width: 753px) 100vw, 753px" /></a><p id="caption-attachment-11846" class="wp-caption-text">Load Zendesk Data into SQL Server Using SSIS JSON Connector (REST API)</p></div></li>
<li>Now execute the package. If you have multiple pages in response, you will notice several requests in the log (e.g., &amp;page=1 &#8230; &amp;page=2 &#8230;).<br />
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: In below screenshot we used per_page=2 for example purpose only. In reality, make it bigger, e.g., per_page=100 or per_page=200, so you don&#8217;t hit the server too often. If you&#8217;re not sure, then exclude the per_page parameter from the URL to use the default setting.</div></div>
<div id="attachment_11845" style="width: 1099px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11845" class="size-full wp-image-11845" src="https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server.png" alt="" width="1089" height="416" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server.png 1089w, https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server-300x115.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server-1024x391.png 1024w, https://zappysys.com/blog/wp-content/uploads/2015/10/Execute-SSIS-Package-Extract-data-from-Zendesk-and-load-into-SQL-Server-768x293.png 768w" sizes="(max-width: 1089px) 100vw, 1089px" /></a><p id="caption-attachment-11845" class="wp-caption-text">Execute SSIS Package &#8211; Extract data from Zendesk and load into SQL Server</p></div></li>
</ol>
<h2>Method-3: Zendesk API Access using Username and Password in SSIS (Basic Authentication)</h2>
<p>This method is the same as the second method outlined in the previous section. Except for a few changes. When you create an HTTP Connection, use your Username (without appenTokentoken ). For the Password, use your account password (the same one you use to log in to the Zendesk portal)</p>
<h2>Zendesk API Rate Limit (Throttling)</h2>
<p>Zendesk may limit how many calls you can make per second, so make sure to slow down if you get errors about api rate limit. You can slow down by entering Wait time on the Throttling tab of JSON Source (100 means wait 100 ms after each Request &#8230; only useful if pagination is enabled)</p>
<h2>Making things Dynamic (e.g., URL)</h2>
<p>You can use SSIS variables in your URL to make it dynamic. See below</p><pre class="crayon-plain-tag">https://mycompany.zendesk.com/api/v2/items/{{User::TicketNumber}}.json</pre><p>
<h2>Dealing with common errors</h2>
<p><span style="box-sizing: border-box; margin: 0px; padding: 0px;">For detailed instructions to fix common metadata-related errors, <a target="_blank" rel="noopener">read this article</a>.</span></p>
<div id="attachment_11851" style="width: 796px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-PowerPack-Column-Metadata-Editor-i.e.-Change-DataType-Column-Length.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11851" class="size-full wp-image-11851" src="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-PowerPack-Column-Metadata-Editor-i.e.-Change-DataType-Column-Length.png" alt="" width="786" height="471" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-PowerPack-Column-Metadata-Editor-i.e.-Change-DataType-Column-Length.png 786w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-PowerPack-Column-Metadata-Editor-i.e.-Change-DataType-Column-Length-300x180.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/SSIS-PowerPack-Column-Metadata-Editor-i.e.-Change-DataType-Column-Length-768x460.png 768w" sizes="(max-width: 786px) 100vw, 786px" /></a><p id="caption-attachment-11851" class="wp-caption-text">SSIS PowerPack &#8211; Column Metadata Editor (i.e., Change DataType, Column Length)</p></div>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2>Deploy to production</h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<div class="content_block" id="custom_post_widget-2021"><h2>Things have gone bad: Error handling &amp; debugging</h2>
<p style="text-align: justify;">Incidentally, bad things can happen<i>. </i>A remote server may go offline or your server may go out of memory. In any case, you may want to know when that happens and take actions accordingly. For that purpose, you have to redirect bad rows to some other destination. For this example, we will take and use <em>Web API Destination</em>, but basically, you can use any SSIS component:</p>

<h3>Handling errors</h3>
<ol style="margin-left: 0;">
 	<li>Add a <em>Derived Column</em> above <em>Web API Destination</em> with expression <strong>"(DT_WSTR,4000)ZS_JSON_OUT"</strong> and name it <strong>"JsonAsString"</strong>. This will let you see what JSON you are actually passing.</li>
 	<li>Then add a database or file destination or use another <em>Trash Destination</em> for debugging purposes and redirect the bad rows (<span style="color: #d66565;">red arrow</span>) from <em><em>Web API Destination </em></em>into it<em><em>. </em></em>Don't forget to set <span class="lang:default decode:true crayon-inline">Redirect row</span> option for both, <em>Error</em> and <em>Truncation</em> columns:<em><em>
</em></em>
<div class="wp-caption">

<a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-1487 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows.png" alt="Redirect bad rows from &lt;em&gt;Web API Destination&lt;/em&gt; to &lt;em&gt;Trash Destination&lt;/em&gt; when load from SQL Server to Elasticsearch is failing. Add derived column JsonAsString to be able to read JSON you are using." width="739" height="267" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows.png 739w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows-300x108.png 300w" sizes="(max-width: 739px) 100vw, 739px" /></a>
<p class="wp-caption-text">Redirected failed requests from <em>Web API Destination</em> to a desired destination when loading from SQL Server to REST API Service is failing. Derived Column <em>JsonAsString</em> added to be able to read JSON which was passed to Elasticsearch</p>

</div></li>
 	<li>Finally, add a <a href="https://technet.microsoft.com/en-us/library/ms140318%28v=sql.90%29.aspx?f=255&amp;MSPPError=-2147217396" target="_blank" rel="noopener"><em>Data Viewer</em></a> for the red path, if you want to debug the flow. You will be able to see URL, JSON and the error message for each record. You may want to copy-paste <em>ErrorMessage</em> to <em>Notepad </em>if you want it to be more readable:
<div class="wp-caption">

<a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-1494 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling.png" alt="Use Data Viewer to view HTTP requests that failed to be fulfilled in Elasticsearch" width="752" height="280" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling.png 752w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-300x112.png 300w" sizes="(max-width: 752px) 100vw, 752px" /></a>
<p class="wp-caption-text">Use Data Viewer to view HTTP requests that failed to be fulfilled.</p>

</div></li>
</ol>
<div class="su-note" style="border-color: #e5dea5; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;">
<div class="su-note-inner su-clearfix" style="background-color: #fff7b7; border-color: #fffdf1; color: #333333; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;"><strong>NOTE</strong>: You can read more about redirecting rows in <a href="//zappysys.com/blog/ssis-error-handling-in-data-flow-redirect-bad-rows/" target="_blank" rel="noopener">SSIS Error Handling (Redirect bad rows)</a> article.</div>
</div>
<h3>Debugging HTTP requests</h3>
<p style="text-align: justify;">A common thing you have to do when working with HTTP requests is to debug those requests; e.g. to check what headers, body or URL was passed. <span id="Debug_Web_API_call_using_Fiddler"></span>To test how things look behind the scenes we strongly suggest to use <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Fiddler</a> - a popular web debugging tool.</p>
<p style="text-align: justify;">Inside it, you can double-click the URL entry (Right side) to see Request and Response Panels. The top panel is Request (URL, Headers, Body) and Bottom Panel is Response. For https:// (secure URL) make sure you enable HTTPS option in Fiddler (Tools &gt; Options &gt; HTTPS &gt; Check Decrypt https request):</p>

<div id="attachment_2344" class="wp-caption alignnone">

<a href="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png?ssl=1" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-2344 size-full" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png" alt="Debugging Web API call using Fiddler in SSIS" width="1287" height="564" data-attachment-id="2344" data-permalink="https://zappysys.com/blog/pass-authorization-header-redirected-location/ssis-rest-api-call-debug-via-fiddler/#main" data-orig-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png?fit=1287%2C564&amp;ssl=1" data-orig-size="1287,564" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ssis-rest-api-call-debug-via-fiddler" data-image-description="&lt;p&gt;Debugging Web API call using Fiddler in SSIS&lt;/p&gt; " data-medium-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png?fit=300%2C131&amp;ssl=1" data-large-file="https://i1.wp.com/zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png?fit=720%2C316&amp;ssl=1" srcset="https://zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler.png 1287w, https://zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler-300x131.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler-768x337.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/05/ssis-rest-api-call-debug-via-fiddler-1024x449.png 1024w" sizes="(max-width: 1287px) 100vw, 1287px" /></a>
<p class="wp-caption-text">Debugging Web API call using Fiddler in SSIS</p>

</div></div>
<h2>Conclusion</h2>
<p>In this post, you saw how easy it is to read data from Zendesk using the SSIS JSON Source (REST API Connector). <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">Click here to download</a> and try it yourself.</p>
<p><strong>Keywords</strong></p>
<p>Loading Zendesk data into SQL Server<br />
How to read Zendesk tickets in SSIS<br />
Calling Zendesk REST API in SSIS<br />
Fetch Zendesk data using a REST API call in SSIS<br />
Extract Zendesk data using a REST API call in SSIS<br />
Reading data from Zendesk using rest api call<br />
Pulling Zendesk tickets using rest api call</p>
<p>The post <a href="https://zappysys.com/blog/read-zendesk-data-in-ssis-call-rest-api/">How to read Zendesk data in SSIS with REST API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
