<?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>regex Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/regex/</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>regex Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/regex/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to query salesforce data using Bulk API in SSIS</title>
		<link>https://zappysys.com/blog/query-salesforce-data-using-bulk-api-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Thu, 20 Jan 2022 19:07:09 +0000</pubDate>
				<category><![CDATA[SSIS CSV Source]]></category>
		<category><![CDATA[SSIS Salesforce API Task]]></category>
		<category><![CDATA[SSIS Salesforce Connection]]></category>
		<category><![CDATA[bulk api]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[salesforce]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=9507</guid>

					<description><![CDATA[<p>Introduction In our previous post, we saw how to read Salesforce data using SSIS Salesforce Source (Which uses SOAP API under the hood). This may be slow if you have millions of rows because Salesforce Source paginates every 2000 rows, so it&#8217;s not a good option to read millions of rows to iterate on a [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/query-salesforce-data-using-bulk-api-ssis/">How to query salesforce data using Bulk API in SSIS</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 post, we saw how to <a href="https://zappysys.com/blog/export-data-from-salesforce-to-sql-server-using-ssis/" target="_blank" rel="noopener">read Salesforce</a> data using SSIS Salesforce Source (Which uses SOAP API under the hood). This may be slow if you have millions of rows because Salesforce Source paginates every 2000 rows, so it&#8217;s not a good option to read millions of rows to iterate on a large Salesforce dataset (Table or Query). To increase the read speed, you can use BULK API. This article explains how to read salesforce data using BULK API and increase read speed.</p>
<div class="content_block" id="custom_post_widget-2523"><h2><span id="Prerequisites">Prerequisites</span></h2>
Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
<ol style="margin-left: 1.5em;">
 	<li><abbr title="SQL Server Integration Services">SSIS</abbr> designer installed. Sometimes it is referred to as <abbr title="Business Intelligence Development Studio">BIDS</abbr> or <abbr title="SQL Server Data Tools">SSDT</abbr> (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from the Microsoft site</a>).</li>
 	<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
 	<li>Make sure <span style="text-decoration: underline;"><a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a></span> is installed (<a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">download it</a>, if you haven't already).</li>
 	<li>(<em>Optional step</em>)<em>.</em> <a href="https://zappysys.zendesk.com/hc/en-us/articles/360035974593" target="_blank" rel="noopener">Read this article</a>, if you are planning to deploy packages to a server and schedule their execution later.</li>
</ol></div>
<h2>NEW Version (v5.5+)</h2>
<p>In the new version (v5.5), we have added an option to query in Bulk Mode. This means if you have millions of Salesforce object rows to read, no worries; it may be very fast in the new version. Previously, it used to take a long time because it read in batches of 2000 rows in each request. With the Bulk API, the batch size is really large.</p>
<p>Here is how to set Salesforce Bulk API Mode in SELECT query (Read operation).</p>
<ol>
<li>Install new version of SSIS PowerPack. Make sure it is v5.5 or higher.</li>
<li>Open existing Salesforce Source UI</li>
<li>Make sure you <strong>check [Use Bulk API]</strong> option like below. if you do not see this option then most likely you are using older version.<br />
-OR-<br />
Just add <strong>#bulkmode</strong> prefix in the SQL query like below, it will use Bulk API</p>
<div id="attachment_11114" style="width: 687px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-bulk-api-option-soql-select-query.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-11114" class="size-full wp-image-11114" src="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-bulk-api-option-soql-select-query.png" alt="" width="677" height="585" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-bulk-api-option-soql-select-query.png 677w, https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-bulk-api-option-soql-select-query-300x259.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a><p id="caption-attachment-11114" class="wp-caption-text">Bulk API mode for SSIS Salesforce Source (Read Large amount of data using SOQL Query)</p></div></li>
</ol>
<h2>OLD Version</h2>
<p>If you are using an older version of SSIS Power Pack (v5.4.0 or older), you can follow the steps mentioned in the following section.</p>
<p>We will see how to query using Salesforce Bulk API in SSIS. It involves three simple steps like the one below.</p>
<ol>
<li>Call BULK API &#8211; Submit SOQL Query and receive a JobId back (Use <a href="https://zappysys.com/products/ssis-powerpack/ssis-salesforce-api-task/">SSIS Salesforce API Task</a>)<br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query</pre>
</li>
<li>Keep checking Job Status Until Status is <strong>JobComplete</strong> (Use <a href="https://zappysys.com/products/ssis-powerpack/ssis-salesforce-api-task/">SSIS Salesforce API Task</a>)<br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query/{{User::JobId}}</pre>
</li>
<li>Read Query Result  (Use <a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-file-source-flat-file-web-api/" target="_blank" rel="noopener">SSIS CSV Source</a>)<br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query/{{User::JobId}}/results</pre>
</li>
</ol>
<div id="attachment_9515" style="width: 671px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png"><img decoding="async" aria-describedby="caption-attachment-9515" class="size-full wp-image-9515" src="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png" alt="Query Salesforce Data using Bulk API in SSIS (read using SOQL query in Bulk mode / large dataset)" width="661" height="330" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png 661w, https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data-300x150.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-9515" class="wp-caption-text">Query Salesforce Data using Bulk API in SSIS (read using SOQL query in Bulk mode / large dataset)</p></div>
<p>Now, let&#8217;s look at everything in detail.</p>
<h3>Obtain Salesforce Credentials</h3>
<p>The first step to call Salesforce API is to obtain credentials (security token or OAuth ClientId /Secret)</p>
<p>Method#1 &#8211; Check <a href="https://zappysys.com/blog/export-data-from-salesforce-to-sql-server-using-ssis/#Get_Salesforce_Security_Token">this article</a> to use <strong>UserId/ Password / SecretToken</strong><br />
Method#2 &#8211; Check <a href="https://zappysys.com/blog/register-salesforce-app-obtain-client-id-secret-oauth-api-call/">this article</a> to use the <strong>OAuth</strong> Connection Option</p>
<h3>Create Salesforce Connection</h3>
<p>Once we have Salesforce Credentials, we can create a new Salesforce Connection (You can do this from Task UI or the below way)</p>
<ol>
<li>Open Visual Studio ( Assuming you already have SSIS installed along with <a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">ZappySys PowerPack</a> )</li>
<li>Create a New SSIS Package Project.</li>
<li>Right-click on the Connection Manager panel and click on New Connection.<br />
<img decoding="async" class="figureimage" title="SSIS Create New Connection" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/ssis-new-connection.png" alt="SSIS Create New Connection" /></li>
<li>Select <strong>ZS-SALESFORCE</strong> Connection Manager from the Connection Managers list and Click on the Add Button.<br />
<img decoding="async" class="figureimage" title="SSIS Salesforce Connection Manager - ADD" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/salesforce-connection/ssis-salesforce-api-task-connection-1.png" alt="SSIS Salesforce Connection Manager - ADD" /></li>
<li>Now in Connection Manager UI, Enter your SalesForce Credentials (OAuth Client Id/. Secret &#8211;or&#8212; User Name, Password and Security Token), and leave all other properties as it is.<br />
<img decoding="async" class="figureimage" title="SSIS Salesforce Connection Manager UI " src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/salesforce-connection/ssis-salesforce-connection-manager-ui.png" alt="SSIS Salesforce Connection Manager UI " /></li>
</ol>
<h3>Call Create Job &#8211; Retrieve / Save JobId</h3>
<p>Once the connection is created, we can create our first step. Basically, we will call this API to <a href="https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_create_job.htm" target="_blank" rel="noopener">create Job</a> (Bulk Read)</p>
<ol>
<li>Here, in Visual Studio, drag and drop the ZS Salesforce API Task on the design surface.<img decoding="async" class="figureimage" title="SSIS Salesforce API Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/salesforce-api-task/ssis-salesforce-api-task-drag.png" alt="SSIS Salesforce API Task - Drag and Drop" /></li>
<li>Double click the Task and configure Request Settings Tab like below<br />
&#8211; Select Salesforce Connection (Created in the previous section)<br />
&#8211; Check <strong>Use direct URL</strong><br />
&#8211; Enter URL like below (Replace <strong>{your-instance}</strong> with your own instance (i.e. na9) . For more information on how to find out my<br />
salesforce instance id <a href="https://help.salesforce.com/s/articleView?id=000322728&amp;type=1">check this article</a><br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query</pre>
&#8211; Request Method <strong>POST</strong><br />
&#8211; Enter Body like below (You can use your own <a href="https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm" target="_blank" rel="noopener">SOQL query</a>). Keep in mind SQOL must be <a href="https://www.freeformatter.com/json-escape.html" target="_blank" rel="noopener">encoded for JSON format</a>. This means the entire SQL must be in one line (replace new lines with \r\n , quotes with \&#8221; and tabs with \t)<br />
For example, to execute SELECT Id, Name FROM Accounts, you can write something like the one below in BODY.<br />
<pre class="crayon-plain-tag">{
  "operation": "query",
  "query": "SELECT Id, Name\r\nFROM Account"
}</pre>
The above is for below (with a new line)<br />
<pre class="crayon-plain-tag">SELECT Id, Name
FROM Account</pre>
<div id="attachment_9516" style="width: 690px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-query-soql-sql.png"><img decoding="async" aria-describedby="caption-attachment-9516" class="size-full wp-image-9516" src="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-query-soql-sql.png" alt="Create Job - Call Bulk API to Read / Query using SOQL" width="680" height="547" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-query-soql-sql.png 680w, https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-query-soql-sql-300x241.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></a><p id="caption-attachment-9516" class="wp-caption-text">Create Job &#8211; Call Bulk API to Read / Query using SOQL</p></div></li>
<li>Now Click Test Request (Copy the <strong>JobId</strong> which we will use in the Variable for Designtime Testing)</li>
<li>On the Response Tab, configure it like the below.<br />
&#8211; Select Response content Type = Json<br />
&#8211; Enter <strong>$.id</strong> as the expression<br />
&#8211; Check Save response option<br />
&#8211; Select Save to Variable and click New to create a variable. Name it <strong>JobId</strong> and enter a sample <strong>JobId</strong> value (copied from the previous step)</p>
<div id="attachment_9517" style="width: 459px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-extract-jobid-from-result.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9517" class="size-full wp-image-9517" src="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-extract-jobid-from-result.png" alt="Extract Salesforce JobId save to SSIS Variable" width="449" height="236" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-extract-jobid-from-result.png 449w, https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-call-salesforce-bulk-api-extract-jobid-from-result-300x158.png 300w" sizes="(max-width: 449px) 100vw, 449px" /></a><p id="caption-attachment-9517" class="wp-caption-text">Extract Salesforce JobId save to SSIS Variable</p></div></li>
</ol>
<h3>Do Status Check &#8211; Look for JobComplete</h3>
<p>Once we create a job and store JobId in the variable we have to keep <a href="https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_one_job.htm" target="_blank" rel="noopener">checking Job status</a> every X seconds. Don&#8217;t worry you don&#8217;t have to use Loop or timer control for that. ZappySys made it so simple to check such thing without Loop /Timer.</p>
<ol>
<li>Drag and drop the ZS Salesforce API Task in the design surface.<img decoding="async" class="figureimage" title="SSIS Salesforce API Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/salesforce-api-task/ssis-salesforce-api-task-drag.png" alt="SSIS Salesforce API Task - Drag and Drop" /></li>
<li>Double click and configure like below. URL will be different this time. Use variable as below and replace your instance ID<br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query/{{User::JobId}}</pre>
<div id="attachment_9518" style="width: 720px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9518" class="size-full wp-image-9518" src="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check.png" alt="Check Salesforce Job Status Periodically (Without Loop + Timer Controls) " width="710" height="566" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check.png 710w, https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check-300x239.png 300w" sizes="(max-width: 710px) 100vw, 710px" /></a><p id="caption-attachment-9518" class="wp-caption-text">Check Salesforce Job Status Periodically (Without Loop + Timer Controls)</p></div></li>
<li>Now go to the Status Check Tab and configure it, as shown below. It will keep looking for the words below in the response to decide whether it is a Success or Failure. If those words are not found, they will be checked every 5 seconds (Maximum 1200 secs).<br />
&#8211; Check Enable Status Check option<br />
&#8211; For Success Value &#8211; Enter <strong>JobComplete</strong><br />
-Check Fail task option<br />
&#8211; Enter <strong>Cancel|Failed|Abort</strong> in the text box</p>
<div id="attachment_9519" style="width: 709px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9519" class="size-full wp-image-9519" src="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check-2.png" alt="Configure Job Status Check Loop using Salesforce API Task" width="699" height="640" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check-2.png 699w, https://zappysys.com/blog/wp-content/uploads/2022/01/ssis-salesforce-api-job-status-check-2-300x275.png 300w" sizes="(max-width: 699px) 100vw, 699px" /></a><p id="caption-attachment-9519" class="wp-caption-text">Configure Job Status Check Loop using Salesforce API Task</p></div></li>
</ol>
<h2></h2>
<h3>Read data (Compressed CSV Format)</h3>
<p>Last step is <a href="https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_job_results.htm" target="_blank" rel="noopener">read the result</a> from completed Salesforce Job. Its in CSV format so we will use Advanced <a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-file-source-flat-file-web-api/" target="_blank" rel="noopener">SSIS CSV Source</a> which supports API connection to Salesforce. For that, we will use the same Salesforce API Task used before.</p>
<ol>
<li>Drag and Drop SSIS Data Flow Task from SSIS Toolbox.<br />
<img decoding="async" class="figureimage" title="SSIS Data Flow Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/drag-and-drop-data-flow-task.png" alt="SSIS Data Flow Task - Drag and Drop" /></li>
<li>Double click on the DataFlow task to see DataFlow designer surface.</li>
<li>Here, In Visual Studio, drag and drop the ZS CSV Source (Web API or File) in the design panel<br />
<img decoding="async" class="figureimage" title="SSIS CSV Source (Web API or File) - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/csv-source/ssis-csv-file-source-drag.png" alt="SSIS CSV Source (Web API or File) - Drag and Drop" /></li>
<li>Double click on ZS CSV Source (Web API or File) Configure it like below.<br />
&#8211; Enter URL to read result like this (You can supply OPTIONAL maxRecords parameters to control how much data comes in a single response)<br />
<pre class="crayon-plain-tag">https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query/{{User::JobId}}/results
--OR--
https://{your-instance}.salesforce.com/services/data/v50.0/jobs/query/{{User::JobId}}/results?maxRecords=50000</pre>
&#8211; Check Use Credentials and select Salesforce Connection<br />
&#8211; Click Preview (assuming JobId variable has a valid completed JobId)</p>
<div id="attachment_9520" style="width: 689px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/read-salesforce-data-bulk-api-csv-result.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9520" class="size-full wp-image-9520" src="https://zappysys.com/blog/wp-content/uploads/2022/01/read-salesforce-data-bulk-api-csv-result.png" alt="Read Salesforce Bulk API Job Result - Using SSIS CSV / API Source" width="679" height="663" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/read-salesforce-data-bulk-api-csv-result.png 679w, https://zappysys.com/blog/wp-content/uploads/2022/01/read-salesforce-data-bulk-api-csv-result-300x293.png 300w" sizes="(max-width: 679px) 100vw, 679px" /></a><p id="caption-attachment-9520" class="wp-caption-text">Read Salesforce Bulk API Job Result &#8211; Using SSIS CSV / API Source</p></div></li>
<li>Now, set up Pagination as below to read all records using an automated loop. You will need <strong>VERSION Released after Jun 20, 2022</strong> to use Regular Expression feature in Header Value extractionBy default, Salesforce doesn&#8217;t send all records in response so we <a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/#Method-7_REST_APIPagination_using_Cursor_Continuation_Token_from_Response_Header" target="_blank" rel="noopener">need to setup pagination</a>. In below example we are reading <strong>Sforce-Locator</strong> attribute from Response and sending it to the next URL as <strong>locator=&lt;continue-token&gt;</strong> value<br />
&#8211; Choose <strong>Response Header Contains Continue Token </strong><br />
&#8211; Enter below expression in <strong>Page Num Indicator</strong><br />
<pre class="crayon-plain-tag">locator=Sforce-Locator(^((?!null\b).)*$)</pre>
Basically, the above expression will keep looping until we find <strong>Sforce-Locator : null</strong> in the response header.</p>
<div id="attachment_9723" style="width: 872px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-bulk-query-api-pagination-read-csv-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9723" class="size-full wp-image-9723" src="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-bulk-query-api-pagination-read-csv-data.png" alt="Pagination for Salesforce Bulk Query API (Get Header Value from Sforce-Locator)" width="862" height="523" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-bulk-query-api-pagination-read-csv-data.png 862w, https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-bulk-query-api-pagination-read-csv-data-300x182.png 300w, https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-bulk-query-api-pagination-read-csv-data-768x466.png 768w" sizes="(max-width: 862px) 100vw, 862px" /></a><p id="caption-attachment-9723" class="wp-caption-text">Pagination for Salesforce Bulk Query API (Get Header Value from Sforce-Locator)</p></div></li>
<li>Click OK to save and now run entire package like below.</li>
</ol>
<div id="attachment_9515" style="width: 671px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png"><img decoding="async" aria-describedby="caption-attachment-9515" class="size-full wp-image-9515" src="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png" alt="Query Salesforce Data using Bulk API in SSIS (read using SOQL query in Bulk mode / large dataset)" width="661" height="330" srcset="https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data.png 661w, https://zappysys.com/blog/wp-content/uploads/2022/01/salesforce-query-bulk-api-read-data-300x150.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-9515" class="wp-caption-text">Query Salesforce Data using Bulk API in SSIS (read using SOQL query in Bulk mode / large dataset)</p></div>
<h2>Conclusion</h2>
<p>In this article we saw how to use various ZappySys Components / Task to achieve complex Salesforce API calls to read Query data using Bulk API. Download <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> and try yourself and also explore 70+ other tasks /components not discussed in this article.</p>
<p>The post <a href="https://zappysys.com/blog/query-salesforce-data-using-bulk-api-ssis/">How to query salesforce data using Bulk API in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Extract audit data from SSIS Execution Log (EventHandler and Regular Expression)</title>
		<link>https://zappysys.com/blog/extract-audit-data-ssis-execution-log-eventhandler-regular-expression/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 26 May 2020 20:11:33 +0000</pubDate>
				<category><![CDATA[SSIS CSV Export Task]]></category>
		<category><![CDATA[SSIS Logging Task]]></category>
		<category><![CDATA[SSIS Regex Parser Task]]></category>
		<category><![CDATA[audit]]></category>
		<category><![CDATA[EventHandler]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[ssis]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=8928</guid>

					<description><![CDATA[<p>Introduction In our last post (Regex Cheat Sheet) we explained use cases of SSIS Regular Expression Parser Task . Now lets look at some real world usecase. Basically in this article we are going to Extract data from audit log using SSIS. For demo purpose we will use log generated by SSIS Export CSV File Task output. When [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/extract-audit-data-ssis-execution-log-eventhandler-regular-expression/">Extract audit data from SSIS Execution Log (EventHandler and Regular Expression)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In our <a href="https://zappysys.com/blog/using-regular-expressions-in-ssis/" target="_blank" rel="noopener">last post</a> (Regex Cheat Sheet) we explained use cases of <a href="https://zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regular Expression Parser Task</a> . Now lets look at some real world usecase. Basically in this article we are going to Extract data from audit log using SSIS. For demo purpose we will use log generated by <a href="https://zappysys.com/products/ssis-powerpack/ssis-export-csv-file-task/" target="_blank" rel="noopener">SSIS Export CSV File Task output</a>. When you export many tables dynamically using this task you want to know how many Row count exported for each Table. This information is logged in SSIS Output Log but no easy way to capture in SSIS variable. So what we will do we will use few tricks to capture that data using Regular Expression usecase.</p>
<p>So let&#8217;s get started.</p>
<div class="content_block" id="custom_post_widget-2523"><h2><span id="Prerequisites">Prerequisites</span></h2>
Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
<ol style="margin-left: 1.5em;">
 	<li><abbr title="SQL Server Integration Services">SSIS</abbr> designer installed. Sometimes it is referred to as <abbr title="Business Intelligence Development Studio">BIDS</abbr> or <abbr title="SQL Server Data Tools">SSDT</abbr> (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from the Microsoft site</a>).</li>
 	<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
 	<li>Make sure <span style="text-decoration: underline;"><a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a></span> is installed (<a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">download it</a>, if you haven't already).</li>
 	<li>(<em>Optional step</em>)<em>.</em> <a href="https://zappysys.zendesk.com/hc/en-us/articles/360035974593" target="_blank" rel="noopener">Read this article</a>, if you are planning to deploy packages to a server and schedule their execution later.</li>
</ol></div>
<h2>Setup Export CSV Task (Output Multiple Tables to CSV Files Dynamically)</h2>
<p>For example purpose we will use Export CSV File Task but you can use this technique for any other Tasks.</p>
<ol>
<li>Drag and Drop ZS Export CSV Task from SSIS Toolbox and configure as below.<br />
<img decoding="async" class="figureimage" title="SSIS Export to CSV File Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/export-csv-file-task/ssis-export-csv-file-task-drag.png" alt="SSIS Export to CSV File Task - Drag and Drop" /></li>
<li>  Configure Export CSV Task to output multiple tables <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/export-csv-file-task.htm" target="_blank" rel="noopener">as explained here</a></li>
<li>Now create 2 SSIS User Variables
<ol>
<li><strong>FilePath</strong> (String Type)</li>
<li><strong>RowCount</strong> (String Type)</li>
</ol>
</li>
</ol>
<p>That&#8217;s it&#8230; now in the next section we will setup event handler to capture output from Log.</p>
<h2>Setup EventHandle / Extract Audit Data using Regex</h2>
<ol>
<li>Now select task and click <strong>Event Handler tab</strong></li>
<li>Select <strong>Executable Name</strong> from the dropdown, Select Event Name <strong>OnInformation</strong> from Handler Dropdown</li>
<li>Click Create Hyper Link to Create Event Handler like below
<div id="attachment_8929" style="width: 665px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-create-eventhandler.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8929" class="size-full wp-image-8929" src="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-create-eventhandler.png" alt="Create Task Level Event Handler in SSIS" width="655" height="260" srcset="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-create-eventhandler.png 655w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-create-eventhandler-300x119.png 300w" sizes="(max-width: 655px) 100vw, 655px" /></a><p id="caption-attachment-8929" class="wp-caption-text">Create Task Level Event Handler in SSIS</p></div></li>
<li>Now Drag below 3 tasks and connect like this
<ol>
<li>Script Task (We will use as dummy start (No configuration needed)</li>
<li>ZS Regular Expression Parser Task</li>
<li>ZS Logging Task (Optional) but we will use to Output Extracted Values<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-eventhandler-extract-audit-information.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-8930" src="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-eventhandler-extract-audit-information.png" alt="" width="828" height="490" srcset="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-eventhandler-extract-audit-information.png 828w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-eventhandler-extract-audit-information-300x178.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-eventhandler-extract-audit-information-768x454.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a></li>
</ol>
</li>
<li>Connect Dummy Script Task to ZS Regular Expression Parser Task and Right click on Green connected Arrow and Use Expression as below. Click OK to save</li>
<li>Configure ZS Regular Expression Parser Task as below
<ol>
<li>Enter <pre class="crayon-plain-tag">{{System::ErrorDescription}}</pre>  as Direct Value</li>
<li>Enter Below two mappings
<ol>
<li>For RowCount set<br />
<pre class="crayon-plain-tag">Total (\d+) records written to : (.*){{1,1}}</pre>
</li>
<li>For FilePath set<br />
<pre class="crayon-plain-tag">Total (\d+) records written to : (.*){{1,2}}</pre>
</li>
</ol>
</li>
</ol>
</li>
<li>Here is how it will look like
<div id="attachment_8932" style="width: 912px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-regular-expression-extract-audit-log-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8932" class="wp-image-8932 size-full" src="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-regular-expression-extract-audit-log-data.png" alt="Extract data from audit log using SSIS Regular Expression Parser Task" width="902" height="838" srcset="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-regular-expression-extract-audit-log-data.png 902w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-regular-expression-extract-audit-log-data-300x279.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-regular-expression-extract-audit-log-data-768x714.png 768w" sizes="(max-width: 902px) 100vw, 902px" /></a><p id="caption-attachment-8932" class="wp-caption-text">Extract data from audit log using SSIS Regular Expression Parser Task</p></div></li>
<li>Thats it&#8230; Now connect 2nd step to last Logging Task&#8230;. in that Task you can set Text like below just to log extracted data. You can also use Execute SQL Task to log into Database Table<br />
<pre class="crayon-plain-tag">{{User::FilePath}} ===&gt; {{User::RowCount}}</pre>
</li>
<li>Now run Package and you will see audit data we extracted for each file. Once File is exported we capture OnInformation event&#8230; and if Message contains substring like &#8220;records written to&#8221; then we extract data into variable for Row Count and Path then you can save to desired place for auditing purpose<a href="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-log-extracted-audit-information.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-8931" src="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-log-extracted-audit-information.png" alt="" width="656" height="163" srcset="https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-log-extracted-audit-information.png 656w, https://zappysys.com/blog/wp-content/uploads/2020/05/ssis-log-extracted-audit-information-300x75.png 300w" sizes="(max-width: 656px) 100vw, 656px" /></a></li>
</ol>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/extract-audit-data-ssis-execution-log-eventhandler-regular-expression/">Extract audit data from SSIS Execution Log (EventHandler and Regular Expression)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to call SOAP / REST API using Dynamic Token in SSIS / ODBC</title>
		<link>https://zappysys.com/blog/call-soap-rest-api-using-dynamic-token-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 07 Jul 2018 09:03:41 +0000</pubDate>
				<category><![CDATA[HTTP Connection]]></category>
		<category><![CDATA[SSIS XML Source (File / SOAP)]]></category>
		<category><![CDATA[jsonpath]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[xpath]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4378</guid>

					<description><![CDATA[<p>Introduction In this blog, we will learn how to call SOAP / REST API using Dynamic Token in SSIS (i.e. Two steps authentication approach &#8211; Fist Call Login API to get token and then call API). In our previous blog post, we saw how to call Web API using some industry standards approaches, such as [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/call-soap-rest-api-using-dynamic-token-ssis/">How to call SOAP / REST API using Dynamic Token in SSIS / ODBC</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/06/REST-API-icon.jpg"><img loading="lazy" decoding="async" class="size-full wp-image-4254 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/06/REST-API-icon.jpg" alt="Logo REST API" width="217" height="232" /></a>In this blog, we will learn how to call SOAP / REST API using Dynamic Token in SSIS (i.e. Two steps authentication approach &#8211; Fist Call Login API to get token and then call API).</p>
<p>In our previous blog post, we saw how to call Web API using some industry standards approaches, such as <a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">OAuth 2.0 Authorization</a> or <a href="https://zappysys.com/blog/how-to-set-base64-encoded-authorization-header-for-http-web-request/" target="_blank" rel="noopener">Basic Authorization</a>. However, not all APIs follow the industry standard to authenticate API requests. After talking with many customers we noticed that very common non-standard technique to authenticate API is Dynamic Token Approach. In this approach first, you have to call Login request to get a temporary token (i.e. sessionid ). Once you get that temp token you can supply it along with your API requests. These temp token/session id usually expires in short time (i.e. expire in one hour or so).</p>
<p>Sounds complicated? Well not really if you use ZappySys <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> or <a href="https://zappysys.com/products/odbc-powerpack/" target="_blank" rel="noopener">ODBC Drivers for API</a>. In this post, we will go through the steps, to authenticate using Dynamic Token approach. We will show you features of  <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm">ZappySys SSIS HTTP Connection Manager</a>. For example purpose, we will call XML SOAP API using <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/">SSIS XML Source Connector</a> but same concepts can be applied to read from JSON API using  <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON Source Connector</a> or CSV API using <a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-file-source-flat-file-web-api/" target="_blank" rel="noopener">CSV Source Connector</a>.</p>
<p>So let&#8217;s get started.</p>
<h2></h2>
<div class="content_block" id="custom_post_widget-2523"><h2><span id="Prerequisites">Prerequisites</span></h2>
Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
<ol style="margin-left: 1.5em;">
 	<li><abbr title="SQL Server Integration Services">SSIS</abbr> designer installed. Sometimes it is referred to as <abbr title="Business Intelligence Development Studio">BIDS</abbr> or <abbr title="SQL Server Data Tools">SSDT</abbr> (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from the Microsoft site</a>).</li>
 	<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
 	<li>Make sure <span style="text-decoration: underline;"><a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a></span> is installed (<a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">download it</a>, if you haven't already).</li>
 	<li>(<em>Optional step</em>)<em>.</em> <a href="https://zappysys.zendesk.com/hc/en-us/articles/360035974593" target="_blank" rel="noopener">Read this article</a>, if you are planning to deploy packages to a server and schedule their execution later.</li>
</ol></div>
<h2>Getting Started</h2>
<p>In order to start, we will show several examples. ZappySys includes an <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/">SSIS XML Source Connector</a> and  <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON Source Connector</a> that will help you to call SOAP / REST API, read various data from SOAP / REST API with SSIS.</p>
<p>To get token from login / authentication URL you have to gather a few pieces from your API documentation.</p>
<ul>
<li>How to call Login API for your API &#8211; (This is not the same URL as Vendor Site Login Page, but its usually API Login endpoint e.g. https://somecompany/api/v2/login)</li>
<li>API Response Format (e.g. JSON, XML ,CSV or Random Text )</li>
</ul>
<p>In our below example steps, we will use XML API which requires POST method first to pass Userid / password to authenticate. If Authentication is successful it may return a response in XML format which contains token.</p>
<p>In the next step, we will call other API (e.g. get-data) and pass token as Authorization Header. All these steps will be done automatically using  <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm">ZappySys SSIS HTTP Connection Manager</a>.</p>
<h2>Create HTTP Connection for Dynamic Token</h2>
<p>To get API response data using SOAP / REST API call, you need to get an API Token from your login request URL. I am using ZappySys sample SOAP API to show you for the Demo purpose. Follow the steps mentioned below to get API Token:</p>
<h3>Create in SSIS</h3>
<ol>
<li>Right Click on Connection Managers Window, and one Context menu appears for creating a new connection manager.
<div id="attachment_10775" style="width: 742px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10775" class="size-full wp-image-10775" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-connection.png" alt="Select new connection" width="732" height="446" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-connection.png 732w, https://zappysys.com/blog/wp-content/uploads/2018/07/Select-connection-300x183.png 300w" sizes="(max-width: 732px) 100vw, 732px" /></a><p id="caption-attachment-10775" class="wp-caption-text">Connection Manager Window: Create New Connection</p></div>
<div class="mceTemp"></div>
</li>
<li>Select ZS HTTP Connection Manager from the list of Connection Managers and, double-click on it or click on Add button to add a new Connection Manager. By Default, The created connection manager is of Package-Level. You can set Project Level Connection manager too If you want.
<div id="attachment_10776" style="width: 486px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-HTTP-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10776" class="size-full wp-image-10776" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-HTTP-connection.png" alt="Connection list from SSIS" width="476" height="487" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Select-HTTP-connection.png 476w, https://zappysys.com/blog/wp-content/uploads/2018/07/Select-HTTP-connection-293x300.png 293w" sizes="(max-width: 476px) 100vw, 476px" /></a><p id="caption-attachment-10776" class="wp-caption-text">List of SSIS Connection Managers – Select HTTP Connection Manager</p></div></li>
</ol>
<h3>Create in ODBC</h3>
<p>To use HTTP Connection in ODBC Drivers you can change connection Type to HTTP like below and it will show similar UI discussed in this article.</p>
<div id="attachment_10777" style="width: 814px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Create-HTTP-connection-in-ODBC.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10777" class="size-full wp-image-10777" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Create-HTTP-connection-in-ODBC.png" alt="New HTTP connection in ODBC" width="804" height="522" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Create-HTTP-connection-in-ODBC.png 804w, https://zappysys.com/blog/wp-content/uploads/2018/07/Create-HTTP-connection-in-ODBC-300x195.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/Create-HTTP-connection-in-ODBC-768x499.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></a><p id="caption-attachment-10777" class="wp-caption-text">Create an HTTP connection inside an ODBC driver</p></div>
<h2>Configure HTTP Connection Credential Type</h2>
<p>Once you add new SSIS ZS HTTP Connection Manager, Go to General Tab and Configure HTTP Connection Manager for Two Step Authorization Flow. Enter API URL, Login Credentials, and configure some basic settings for the same. We used Login URL as just example but you can enter any valid API URL endpoint here. Actual Login URL goes on Dynamic Token Tab (see next step)</p>
<div id="attachment_10778" style="width: 628px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-general-tab.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10778" class="size-full wp-image-10778" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-general-tab.png" alt="HTTP connection with dynamic token in ODBC" width="618" height="515" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-general-tab.png 618w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-general-tab-300x250.png 300w" sizes="(max-width: 618px) 100vw, 618px" /></a><p id="caption-attachment-10778" class="wp-caption-text">SSIS ZS HTTP Connection Manager: General Tab Configurations Settings</p></div>
<h2>Configure Request Settings</h2>
<p>Once you enter Username / password details on General Tab now we need to setup some information like Login Request URL, Body, Headers. Lets look at few options.</p>
<h3><strong>Passing User ID /Password in Body</strong></h3>
<ol>
<li>Go to Dynamic Token tab, Enter the following pieces.
<ol>
<li>Token/API Login URL<br />
For our example enter API Login URL as:<br />
<pre class="crayon-plain-tag">https://zappysys.com/downloads/files/test/soap-login.aspx</pre></li>
<li>Request Method as <strong>POST</strong></li>
<li>Request Body as below. Notice we used <pre class="crayon-plain-tag">[$userid$]</pre>  and <pre class="crayon-plain-tag">[$password$]</pre>  placeholders. These are replaced automatically at runtime so you do not have to hard code in Body and keep it secure. (See General Tab to enter UserID/Password)<br />
<strong>Pass User ID / Password in Body</strong><br />
<pre class="crayon-plain-tag">&lt;soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:urn=""urn:partner.soap.sforce.com""&gt;
   &lt;soapenv:Body&gt;
      &lt;urn:login&gt;
         &lt;urn:username&gt;[$userid$]&lt;/urn:username&gt;
         &lt;urn:password&gt;[$password$]&lt;/urn:password&gt;
      &lt;/urn:login&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre>
</li>
<li>Select Request Body Content Type. For JSON data it may be application/json. For Key/Value Pair  <strong>key1=value1&amp;key2=value2</strong> leave it Default.<strong>Passing User ID /Password in Request BODY</strong>
<div id="attachment_10779" style="width: 858px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-tab.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10779" class="size-full wp-image-10779" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-tab.png" alt="HTTP connection dynamic tab" width="848" height="797" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-tab.png 848w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-tab-300x282.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-tab-768x722.png 768w" sizes="(max-width: 848px) 100vw, 848px" /></a><p id="caption-attachment-10779" class="wp-caption-text">SSIS ZS HTTP Connection Manager: Dynamic Token Tab Configurations Settings of Request Tab</p></div></li>
</ol>
</li>
</ol>
<h3><strong>Passing User ID / Password in URL (GET Request)</strong></h3>
<p>Our Example API pass credentials in the <strong>POST</strong> body but some API may pass via URL as <strong>GET</strong> request.</p>
<p>In such case, you can enter like this<br />
<pre class="crayon-plain-tag">https://mysite.com/api/v2/login?userid=[$userid$]&amp;password=[$password$]</pre>
Notice in above URL we used <pre class="crayon-plain-tag">[$userid$]</pre>  and <pre class="crayon-plain-tag">[$password$]</pre>   placeholders. These are replaced automatically at runtime (See General Tab to enter UserID/Password)</p>
<h3><strong>Passing User ID /Password in Header as Basic Authentication</strong></h3>
<p>Another scenario is API requires <a href="https://zappysys.com/blog/how-to-set-base64-encoded-authorization-header-for-http-web-request/" target="_blank" rel="noopener">HTTP Basic authentication</a>, (Pass User ID / Password in Header as Base64 encoded value) then you can pass credentials like this:</p>
<p><code style="margin-bottom: 10pt;">Authorization: Basic &lt;&lt;[$userid$]:[$password$],FUN_BASE64ENC&gt;&gt;<br />
</code></p>
<p>Here we have used <code style="margin-bottom: 10pt;">FUN_BASE64ENC</code> function but there are <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-format-specifiers.htm" target="_blank" rel="noopener">many other functions</a> can be used anywhere in Body or Headers</p>
<div id="attachment_10780" style="width: 652px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-header-ODBC.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10780" class="size-full wp-image-10780" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-header-ODBC.png" alt="HTTP connection dynamic token in header request credentials" width="642" height="512" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-header-ODBC.png 642w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-configuration-header-ODBC-300x239.png 300w" sizes="(max-width: 642px) 100vw, 642px" /></a><p id="caption-attachment-10780" class="wp-caption-text">Using Basic Authentication in Dynamic Token approach</p></div>
<h2>Configure Response Settings</h2>
<p>Now lets configure how to extract token (single value) from response. Which can be XML, JSON or sometimes Raw Text. We support 4 modes (default = None means full response text is treated as token). If you want to extract just single value and not full text then use below settings.</p>
<h3>XML Expression Type (Use XPath)</h3>
<ol>
<li>Now, Go to Response Settings tab under a Dynamic Token tab, Enter Response Settings like Token Extract Mode, Expression Type, Content Filter Expression as below XPath Expression. The expression basically extracts content from sessionid XML node using below <a href="https://zappysys.com/blog/ssis-extract-single-xml-node-using-xpath-soap-response/" target="_blank" rel="noopener">XPath Expression</a>.<pre class="crayon-plain-tag">//*[local-name()='sessionid']</pre>
<div id="attachment_10781" style="width: 650px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10781" class="size-full wp-image-10781" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab.png" alt="Get XML response for dynamic token" width="640" height="510" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab.png 640w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-300x239.png 300w" sizes="(max-width: 640px) 100vw, 640px" /></a><p id="caption-attachment-10781" class="wp-caption-text">ODBC ZS HTTP Connection Manager: Dynamic Token Tab Configurations Settings of Response Tab</p></div></li>
<li>That&#8217;s it click on OK button to save your Connection Manager Configurations.</li>
</ol>
<h3>JSON Expression Type (Use JSONPath)</h3>
<p>If you API returns JSON response (like <a href="https://zappysys.com/blog/read-walmart-api-data-ssis-odbc/">Walmart API Example</a>) then you can do something like below. Choose Expression Type=JSON and in Response Content Filter You can enter expression like $.some_property_name  (e.g. $.access_token). Check more about How to write <a href="https://zappysys.com/blog/jsonpath-examples-expression-cheetsheet/">JSON Path expression here</a>.</p>
<div id="attachment_10782" style="width: 793px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-SSIS.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10782" class="size-full wp-image-10782" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-SSIS.png" alt="Walmart API – Extract Token – Response Settings" width="783" height="646" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-SSIS.png 783w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-SSIS-300x248.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-SSIS-768x634.png 768w" sizes="(max-width: 783px) 100vw, 783px" /></a><p id="caption-attachment-10782" class="wp-caption-text">SSIS ZS HTTP Connection Manager &#8211; Get a JSON response for the token</p></div>
<h3>Regular Expression Type (Use Regex)</h3>
<p>Another advanced mode to extract token from response is Regex Mode. You can write any valid regular expression <a href="https://zappysys.com/blog/using-regular-expressions-in-ssis/" target="_blank" rel="noopener">like this one</a> to extract just one value.</p>
<p>For example if your response returns raw string with token in double quotes but you want just token and no double quotes around it then try something like below.</p>
<div id="attachment_10783" style="width: 793px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-regex-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10783" class="size-full wp-image-10783" src="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-regex-example.png" alt="Dynamic token from a regex expression" width="783" height="646" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-regex-example.png 783w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-regex-example-300x248.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/HTTP-connection-dynamic-token-response-settings-tab-regex-example-768x634.png 768w" sizes="(max-width: 783px) 100vw, 783px" /></a><p id="caption-attachment-10783" class="wp-caption-text">Extract Token from response – Remove double quotes around value using Regular Expression</p></div>
<h2><strong>Call API </strong><strong>in SSIS with </strong><strong>Dynamic API Token</strong></h2>
<p>Now once you have setup HTTP connection manager to authenticate and get API token, we are ready for next step. Now we can use that token in SOAP / REST API Service call. So, let&#8217;s move to the SSIS Part.</p>
<ol>
<li>Once SSIS Package is open, Goto Data Flow Section, For that Drag and Drop DataFlow Task from the SSIS Toolbox.
<div id="attachment_10784" style="width: 472px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-data-flow.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10784" class="wp-image-10784 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-data-flow.png" alt="Use data flow " width="462" height="157" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-data-flow.png 462w, https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-data-flow-300x102.png 300w" sizes="(max-width: 462px) 100vw, 462px" /></a><p id="caption-attachment-10784" class="wp-caption-text">Drag and drop Data flow task</p></div></li>
<li>Now, Drag and Drop SSIS ZS XML Source Component from the SSIS Toolbox (if your API is JSON based then drag ZS JSON Source).
<div id="attachment_10785" style="width: 854px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-XML-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10785" class="wp-image-10785 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-XML-source.png" alt="Drag and Drop ZS SSIS XML Source Component" width="844" height="401" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-XML-source.png 844w, https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-XML-source-300x143.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/SSIS-drag-and-drop-XML-source-768x365.png 768w" sizes="(max-width: 844px) 100vw, 844px" /></a><p id="caption-attachment-10785" class="wp-caption-text">Drag and Drop ZS SSIS XML Source Component</p></div></li>
<li>Let&#8217;s double-click on XML Source Component to configure it&#8217;s Properties. Enter Request URL.<br />
<pre class="crayon-plain-tag">https://zappysys.com/downloads/files/test/soap-getdata.aspx</pre>
<div id="attachment_10786" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-URL.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10786" class="wp-image-10786 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-URL.png" alt="Enter URL to XML source" width="828" height="735" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-URL.png 828w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-URL-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-URL-768x682.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10786" class="wp-caption-text">SSIS XML Source: Enter your SOAP Request URL</p></div></li>
<li>Check Use Credentials (Username/Password OR Token), Select HTTP Connection Manager from the drop-down list, we have created just before.
<div id="attachment_10787" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-credential.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10787" class="wp-image-10787 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-credential.png" alt="USe a credentials inside XML source" width="828" height="374" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-credential.png 828w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-credential-300x136.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-enter-credential-768x347.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10787" class="wp-caption-text">ZS SSIS XML Source Component: Check Use Credentials and Select Connection Manager</p></div></li>
<li>Select the Request Method and Enter SOAP Request Body something like this. Notice that we used <strong>[$token$]</strong> as a placeholder. This is automatically replaced at runtime by ZS-HTTP Connection Manager.<strong>Passing Token in Body</strong><br />
<pre class="crayon-plain-tag">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com"&gt;
   &lt;soapenv:Body&gt;
      &lt;urn:sessionid&gt;[$token$]&lt;/urn:sessionid&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre>
<strong>Passing Token in Header<br />
</strong><br />
If your API expects token via HTTP Header (e.g. <strong>Authorization:</strong> <strong>xxxx-my-token-xxxxxxxx</strong> ) then make sure you configure Auth Scheme and Header name on HTTP Connection. By default it sends Token in Authorization header if you dont do anything.</p>
<div id="attachment_10788" style="width: 836px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-Header.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10788" class="size-full wp-image-10788" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-Header.png" alt="Dynamic Token in the header" width="826" height="733" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-Header.png 826w, https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-Header-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-Header-768x682.png 768w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-10788" class="wp-caption-text">ZS SSIS XML Source Component: Enter SOAP Request Body</p></div></li>
<li>Select Content-Type as per your Request, here we are selecting <pre class="crayon-plain-tag">text/XML;charset=UTF-8</pre>  and adding 1 HTTP Header: <pre class="crayon-plain-tag">SOAPAction: "https://zappysys.com/soap-getdata"</pre>
<div id="attachment_10789" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-body.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10789" class="size-full wp-image-10789" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-body.png" alt="Select Content-Type Add HTTP Request Header" width="828" height="742" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-body.png 828w, https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-body-300x269.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/Passing-Token-in-body-768x688.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10789" class="wp-caption-text">ZS SSIS XML Source Component: Select Content-Type Add HTTP Request Header</p></div></li>
<li>select Filter Path: set as per your requirements. here for this example, we are setting:<br />
<pre class="crayon-plain-tag">$.soapenv:Envelope.soapenv:Body.urn:Row[*]</pre>
<div id="attachment_10790" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10790" class="size-full wp-image-10790" src="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result.png" alt="XML source filter with dynamic token" width="828" height="742" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result.png 828w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-300x269.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-768x688.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10790" class="wp-caption-text">ZS SSIS XML Source Component: Select Filter</p></div>
<p>&nbsp;</li>
<li>Check Include Parent Columns checkbox, for including parent Columns, and then click on Preview button to see the Preview data.
<div id="attachment_10791" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-preview.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10791" class="size-full wp-image-10791" src="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-preview.png" alt="Preview data XML source dynamic token" width="828" height="742" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-preview.png 828w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-preview-300x269.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/XML-source-dynamic-token-result-preview-768x688.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10791" class="wp-caption-text">SSIS XML Source Component: See the Preview data</p></div></li>
<li>That&#8217;s it. Click on OK button to Save your Configuration.</li>
<li>Finally drag any destination (i.e. OLEDB Destination) from your SSIS toolbox. If you want to load this data into SQL, then Drag OLE DB Destination Component, and configure it.</li>
</ol>
<h2><span id="Conclusion">Conclusion</span></h2>
<p>In this blog, we learned how to call any SOAP/REST API with Dynamic Token, retrieve Service response data with SSIS using <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/">XML Source <span style="color: #0000ee;"><u>Component</u></span></a> OR <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/">JSON Source Component</a>   in a very simple way. Furthermore, you can achieve many more functionalities with this tool. Check our blogs/articles on <strong>XML Source Component </strong>to find out what <em>this tool</em> is capable of more.</p>
<h2><span id="References">References</span></h2>
<p>Finally, you can use the following links for more information about the call any SOAP / REST API with Dynamic Token feature with our tools:</p>
<ul>
<li><strong>Landing Page</strong> for <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/">XML Source</a>, you can also find <a href="https://youtu.be/2Li6Vy-nQvw">Tutorial Video</a> here.</li>
<li><strong>Help File:</strong> Documentation of <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-xml-source.htm">XML Source</a>.</li>
</ul>
<p>The post <a href="https://zappysys.com/blog/call-soap-rest-api-using-dynamic-token-ssis/">How to call SOAP / REST API using Dynamic Token in SSIS / ODBC</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using Regular Expressions in SSIS</title>
		<link>https://zappysys.com/blog/using-regular-expressions-in-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Wed, 07 Mar 2018 17:38:24 +0000</pubDate>
				<category><![CDATA[SSIS Advanced File System Task]]></category>
		<category><![CDATA[SSIS Amazon Storage Task]]></category>
		<category><![CDATA[SSIS Azure Blob Storage Task]]></category>
		<category><![CDATA[SSIS Regex Parser Task]]></category>
		<category><![CDATA[SSIS SFTP Task]]></category>
		<category><![CDATA[SSIS Tasks]]></category>
		<category><![CDATA[SSIS Tips & How-Tos]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=2858</guid>

					<description><![CDATA[<p>Introduction In this short article, you will learn how to write Regular expressions in SSIS (i.e. Regex) and what tool to use to test them. You will also find helpful resources on how to write more sophisticated expressions and learn more about them. For demo purposes, we will use FREE SSIS Regex Parser Task to parse and [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/using-regular-expressions-in-ssis/">Using Regular Expressions in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis-regex-parser-task.png"><img loading="lazy" decoding="async" class=" wp-image-2974 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis-regex-parser-task.png" alt="" width="114" height="114" /></a>In this short article, you will learn how to write Regular expressions in SSIS (i.e. Regex) and what tool to use to test them. You will also find helpful resources on how to write more sophisticated expressions and learn more about them. For demo purposes, we will use <strong>FREE</strong> <a href="https://zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regex Parser Task</a> to parse and extract the text using Regex.</p>
<p>&nbsp;</p>
<p>You can use Regular expressions in several SSIS PowerPack connectors:</p>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regex Parser Task (FREE)</a>,</li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-azure-blob-storage-task/" target="_blank" rel="noopener">Azure Blob Storage Task</a>,</li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-file-system-task-advanced/" target="_blank" rel="noopener">Advanced File System Task</a>,</li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-amazon-s3-task/" target="_blank" rel="noopener">Amazon S3 Storage Task</a> and others.</li>
</ul>
<h2>Writing Regular Expressions in SSIS</h2>
<p>Based on the SSIS component you use it will include the filename in filtering options or match the text: See below Syntax to write Regex in ZappySys tools. We support additional construct {{X, Y}} at the end of Regex to control two parameters. This additional construct is useful for data extracted from matching regex. If you want to Test patterns and not worry about data extraction then no need to use last {{<pre class="crayon-plain-tag">Occurance_Index</pre>, <pre class="crayon-plain-tag">Group_Index_Or_Name</pre>}}</p>
<p><strong>Syntax:</strong><br />
<pre class="crayon-plain-tag">&lt;your Regular Expression&gt;[{{Occurance_Index|*[,Group_Index_Or_Name]}}]</pre>
<p><strong>Where:</strong><br />
<pre class="crayon-plain-tag">Occurance_Index</pre>=Occurrence index you want to extract (X=0 means the first match) and * means all matches. Use a minus sign to get an occurrence from reverse (e.g. {{-0}} returns the last match)<br />
<pre class="crayon-plain-tag">Group_Index_Or_Name</pre>=Group index/name within your search pattern (Groups are indicated by parentheses in regular expression, Y=0 means first group). If you named your group in the pattern then you can use the Group name. To use Group Name you must use the new version (the old version doesn&#8217;t support this)</p>
<p><strong>How to name a group?</strong></p>
<p>E.g. (\w+)@(<strong>?&lt;domain&gt;</strong>\w+.com)</p>
<p><strong>How to use the group name in the match extract?</strong></p>
<p>E.g. (\w+)@(<strong>?&lt;domain&gt;</strong>\w+.com){{0,<strong>domain</strong>}}</p>
<p><strong>Example Input:</strong></p>
<p>Let&#8217;s assume we have the following input text. We will test various Expressions.</p><pre class="crayon-plain-tag">Customer =&gt; AAA
Email =&gt; aaa@google.com
Phone =&gt; 101-222-3333
========
Customer =&gt; BBB
Email =&gt; bbb@yahoo.com
Phone =&gt; 102-222-3333
========
Customer =&gt; CCC
Email =&gt; ccc@hotmail.com
Phone =&gt; 103-222-3333
========
Customer =&gt; DDD
Email =&gt; ddd@outlook.com
Phone =&gt; 104-222-3333</pre><p>
<strong>Sample Regex Expressions</strong></p>
<div class="su-table su-table-alternate">
<table style="border-collapse: collapse;width: 100%;height: 332px" border="1">
<tbody>
<tr style="height: 22px">
<td style="width: 50%;height: 22px"><strong>Expression</strong></td>
<td style="width: 50%;height: 22px"><strong>Description</strong></td>
</tr>
<tr style="height: 46px">
<td style="width: 50%;height: 46px">(?s).*</td>
<td style="width: 50%;height: 46px">Match anything including new lines. To match anything without new line just use <pre class="crayon-plain-tag">(.*)</pre></td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">\w+([-+.&#8217;]\w+)*@(?&lt;domain&gt;\w+([-.]\w+)*\.\w+([-.]\w+)*)</td>
<td style="width: 50%;height: 22px">Get first email id from text ({{0}} is omitted from end because {{0}} id default)</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">\w+([-+.&#8217;]\w+)*@(?&lt;domain&gt;\w+([-.]\w+)*\.\w+([-.]\w+)*){{-0}}</td>
<td style="width: 50%;height: 22px">Get last email id from text</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">\w+([-+.&#8217;]\w+)*@(?&lt;domain&gt;\w+([-.]\w+)*\.\w+([-.]\w+)*){{*}}</td>
<td style="width: 50%;height: 22px">Get all email addresses (separate them with new line). When you suffix Regular expression with {{*}} it will return all matches.</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">\w+([-+.&#8217;]\w+)*@(?&lt;domain&gt;\w+([-.]\w+)*\.\w+([-.]\w+)*){{2}}</td>
<td style="width: 50%;height: 22px">Get third email id from text (i.e. ends with {{X}} where X is occurrence index starting from 0)</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">\w+([-+.&#8217;]\w+)*@(?&lt;domain&gt;\w+([-.]\w+)*\.\w+([-.]\w+)*){{0,2}}</td>
<td style="width: 50%;height: 22px">Get first email pattern match (i.e. Index=0) and extract domain (i.e. 2nd group). Index starting from 0 for occurrence and group</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">(\d*)-(\d*)-(\d*)</td>
<td style="width: 50%;height: 22px">Get first phone number from text (If you don&#8217;t include {{X,Y}} at the end then it will be always [0,0])</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">^((?!demo|test).)*$</td>
<td style="width: 50%;height: 22px">Match whole input text if it does not contain words like demo or test. If word found then No Match</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">&lt;tag&gt;((.|\n)*?)&lt;/tag&gt;{{0,1}}</td>
<td style="width: 50%;height: 22px">Extract anything between &lt;tag&gt;&#8230;&lt;/tag&gt; (Include new line char i.e. \n)</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">&lt;tag&gt;(.*)&lt;/tag&gt;{{0,1}}</td>
<td style="width: 50%;height: 22px">Extract anything between &lt;tag&gt;&#8230;&lt;/tag&gt; (Exclude new line char i.e. \n)</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">&lt;!\[CDATA\[((.|\n)*?)\]\]\&gt;{{0,1}}</td>
<td style="width: 50%;height: 22px">Extract content from CData section of XML Data (This can be CSV, JSON or nested XML )</td>
</tr>
<tr style="height: 22px">
<td style="width: 50%;height: 22px">^$</td>
<td style="width: 50%;height: 22px">Match blank string</td>
</tr>
</tbody>
</table>
</div>
<h2>More Regular Expression Examples</h2>
<div class="su-table su-table-alternate">
<table>
<tbody>
<tr>
<td style="width: 196px"><strong>Input Text</strong></td>
<td style="width: 223px"><strong>Regex</strong></td>
<td style="width: 163px"><strong>Matched text</strong></td>
<td style="width: 752px"><strong>Comment</strong></td>
</tr>
<tr>
<td style="width: 196px">&lt;row id=&#8221;123&#8243; process=&#8221;Y&#8221;&gt;</td>
<td style="width: 223px">id=&#8221;([^&#8221;]*)&#8221;{{0,1}}</td>
<td style="width: 163px"><strong>123</strong></td>
<td style="width: 752px">This expression shows how to extract group value (i.e. {{0,1}} &#8211; first match and 2nd group ). It extracts text between double quotes using <strong>[^&#8221;]*</strong> pattern , match anything until double quote is found.  {{0,1}} syntax is ZappySys specific so it may not work with other Regex engines.</td>
</tr>
<tr>
<td style="width: 196px">&lt;data&gt;123&lt;/data&gt;</td>
<td style="width: 223px">&lt;data&gt;([^&lt;]*)&lt;\/data&gt;{{0,1}}</td>
<td style="width: 163px"><strong>123</strong></td>
<td style="width: 752px">This expression shows how to extract group value (i.e. {{0,1}} &#8211; first match and 2nd group ). It extracts text between double quotes using <strong>[^&lt;]*</strong> pattern , match anything until <strong>&lt;</strong>  is found.  {{0,1}} syntax is ZappySys specific so it may not work with other Regex engines.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_source.txt</td>
<td style="width: 223px" valign="top">File</td>
<td style="width: 163px" valign="top"><strong>File</strong></td>
<td style="width: 752px" valign="top">Will match text/filename that has &#8220;File&#8221; keyword in it.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_SOURCE.dat<br />
File_20180930_source.dat</td>
<td style="width: 223px" valign="top">source|SOURCE</td>
<td style="width: 163px" valign="top"><strong>SOURCE</strong> and <strong>source</strong></td>
<td style="width: 752px" valign="top">Will match text/filenames that contain either &#8220;source&#8221; <strong>or</strong> &#8220;SOURCE&#8221; keyword.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_source.txt</td>
<td style="width: 223px" valign="top">File.+source</td>
<td style="width: 163px" valign="top"><strong>File_20180930_source</strong></td>
<td style="width: 752px" valign="top">Will match text/filename that contains keyword that starts with &#8220;File&#8221; <strong>and</strong> ends with &#8220;source&#8221;.<br />
Basically, you can use this pattern if you want to match two keywords in the text that appear in particular order.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_source.txt<br />
File_20180830_source.dat</td>
<td style="width: 223px" valign="top">\.txt$|\.dat$</td>
<td style="width: 163px" valign="top"><strong>.txt</strong> and <strong>.dat</strong></td>
<td style="width: 752px" valign="top">Will match text/all filenames that end with &#8220;.txt&#8221; <strong>or</strong> &#8220;.dat&#8221;.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_source.txt<br />
file_20190102_source.txt</td>
<td style="width: 223px" valign="top">^(F|f)ile_\d{8}</td>
<td style="width: 163px" valign="top"><strong>File_20180930</strong><br />
<strong>file_20190102</strong></td>
<td style="width: 752px" valign="top">Will match text/filename that starts with &#8220;File_&#8221; <strong>or</strong> &#8220;file_&#8221; <strong>and</strong> then followed by 8 digits.</td>
</tr>
<tr>
<td style="width: 196px" valign="top">File_20180930_source.txt<br />
File_20190101_none.txt</td>
<td style="width: 223px" valign="top">(.+)_(.+)_(.+){{0,2}}</td>
<td style="width: 163px" valign="top"><strong>20180930</strong></td>
<td style="width: 752px" valign="top">Will match text that has three groups of text strings, separated by &#8220;_&#8221;.<br />
Non-Regex {{0,2}} notation will bring back second group (index &#8220;2&#8221;) of first match (index &#8220;0&#8221;).</td>
</tr>
<tr>
<td style="width: 196px">File_20180930_source.txt<br />
File_20190101_none.txt</td>
<td style="width: 223px">(.+)_(.+)_(.+){{1,2}}</td>
<td style="width: 163px"><strong>20190101</strong></td>
<td style="width: 752px">Will match text that has three groups of text strings, separated by &#8220;_&#8221;.<br />
Non-Regex {{1,2}} notation will bring back second group (index &#8220;2&#8221;) of second match (index &#8220;1&#8221;).</td>
</tr>
<tr>
<td style="width: 196px">File_20180930_source.txt<br />
File_20190101_none.txt</td>
<td style="width: 223px">(.+)_(.+)_(.+){{*,2}}</td>
<td style="width: 163px"><strong>20180930<br />
20190101<br />
</strong></td>
<td style="width: 752px">Will match text that has three groups of text strings, separated by &#8220;_&#8221;.<br />
Non-Regex {{*,2}} notation will bring back second group (index &#8220;2&#8221;) of all matches (index &#8220;*&#8221;). Returned matches are separated by \r\n</td>
</tr>
<tr>
<td style="width: 196px">&lt;html&gt;<br />
&lt;img src=&#8221;/img-1.png&#8221; /&gt;<br />
&lt;img src=&#8221;/img-2.png&#8221; /&gt;<br />
&lt;img src=&#8221;/img-3.png&#8221; /&gt;<br />
<span style="font-family: inherit;font-size: inherit">&lt;/html&gt;</span></td>
<td style="width: 223px">&lt;img[^&gt;]+src=&#8221;([^&#8221;&gt;]+)&#8221;{{*,1}}</td>
<td style="width: 163px"><strong>/img-1.png<br />
/img-2.png<br />
/img-3.png<br />
</strong></td>
<td style="width: 752px">Will return image URLs from HTML content. We used {{*,1}} means it will pull all occurrences and for each match it will extract first group (which is just src attribute value).</td>
</tr>
<tr>
<td style="width: 196px">null</td>
<td style="width: 223px">^((?!null\b).)*$</td>
<td style="width: 163px"><strong>&lt;blank&gt;</strong></td>
<td style="width: 752px">Returns blank if null word found (match all except null)</td>
</tr>
<tr>
<td style="width: 196px">black white</td>
<td style="width: 223px">^((?!red|blue|orange).)*$</td>
<td style="width: 163px"><strong>black white</strong></td>
<td style="width: 752px">Returns full string as is if any of those 3 words (i.e. red, blue, orange) not found anywhere in the string</td>
</tr>
<tr>
<td style="width: 196px">black white red</td>
<td style="width: 223px">^((?!red|blue|orange).)*$</td>
<td style="width: 163px"><strong>&lt;blank&gt;</strong></td>
<td style="width: 752px">Returns blank if any of those 3 words (i.e. red, blue, orange) found anywhere in the string</td>
</tr>
</tbody>
</table>
</div>
<h2>Regex Examples (Using SSIS Regular Expression Parser Task)</h2>
<p>Here is an example how Regex <pre class="crayon-plain-tag">(.+)_(.+)_(.+){{1,2}}</pre> works in <a href="https://zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">Regular Expression Parser Task (FREE)</a>:</p>
<div id="attachment_2978" style="width: 742px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_parser_task.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2978" class="wp-image-2978 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_parser_task-e1520866478970.png" alt="Using Regular Expressions in SSIS Regex Parser Task (Extract Groups)" width="732" height="612" srcset="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_parser_task-e1520866478970.png 732w, https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_parser_task-e1520866478970-300x251.png 300w" sizes="(max-width: 732px) 100vw, 732px" /></a><p id="caption-attachment-2978" class="wp-caption-text">Using Regular Expressions in SSIS Regex Parser Task (Extract Groups)</p></div>
<h2>Using Groups / Occurrence Index</h2>
<p>Some tasks like <a href="https://zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regex Parser Task (FREE)</a> supports extracting value from specific occurrence and specific part of matched pattern using special syntax at the end of your pattern (see below).</p><pre class="crayon-plain-tag">Your Regex Pattern Here{{OccuranceIndex,GroupIndex}}</pre><p>
<strong>Where :</strong><br />
OccuranceIndex is 0 based (0=extract first occurrence)<br />
GroupIndex is 0 based (0=extract first matching group from pattern. First group is always entire text. )</p>
<p>See above screenshot in previous section for example.</p>
<h2>Tools</h2>
<p>The best tool we&#8217;ve found to write and test Regex is <a href="http://regexhero.net/tester/" target="_blank" rel="noopener">Regex Hero</a> (will require IE with Silverlight if you want to use it online, in the browser):</p>
<p>Another great site for Regex testing is <a href="https://regex101.com" target="_blank" rel="noopener">https://regex101.com</a> (Works in any browser unlike previous one)</p>
<p>and few more sites as below</p>
<p><a href="http://www.regexr.com/" target="_blank" rel="noopener">http://www.regexr.com/</a><br />
<a href="http://www.regexlib.com/" target="_blank" rel="noopener">http://www.regexlib.com/</a><br />
<a href="http://www.regular-expressions.info/" target="_blank" rel="noopener">http://www.regular-expressions.info/</a></p>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_task_using_regex_hero.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2972" src="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_task_using_regex_hero.png" alt="" width="802" height="483" srcset="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_task_using_regex_hero.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_task_using_regex_hero-300x181.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/03/ssis_powerpack_regular_expression_task_using_regex_hero-768x463.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a></p>
<h2>Resources</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/Regular-expressions-quick-reference.pdf">Regular Expressions cheat-sheet to hang on the wall</a></p>
<p><a href="http://www.rexegg.com/regex-quickstart.html" target="_blank" rel="noopener">Regular Expressions quick reference</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/using-regular-expressions-in-ssis/">Using Regular Expressions in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to remove invalid characters from XML using SSIS and Regex</title>
		<link>https://zappysys.com/blog/how-to-remove-invalid-characters-from-xml-using-ssis-and-regex/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 10 Jan 2017 20:27:45 +0000</pubDate>
				<category><![CDATA[SSIS Advanced File System Task]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[ssis advanced file system task]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=926</guid>

					<description><![CDATA[<p> Introduction In this blog post, you will see how to remove invalid characters from XML using SSIS. We will use the search and replace feature of the Advanced File System Task. Remove Invalid characters from XML. The XML file specification specifies which characters can be part of XML data and which should be avoided. If you [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/how-to-remove-invalid-characters-from-xml-using-ssis-and-regex/">How to remove invalid characters from XML using SSIS and Regex</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2> Introduction</h2>
<p>In this blog post, you will see how to remove invalid characters from XML using SSIS. We will use the search and replace feature of the <a target="_blank" rel="noopener">Advanced File System Task</a>.</p>
<h2>Remove Invalid characters from XML.</h2>
<p>The XML file specification specifies which characters can be part of XML data and which should be avoided. If you use an invalid character, the XML Parser can throw an error indicating that it found an invalid character. Here is a <a href="https://en.wikipedia.org/wiki/Valid_characters_in_XML" target="_blank" rel="noopener">very useful link</a> that explains which characters are allowed in XML and which are not.</p>
<h2>Using SSIS and Regex to clean invalid XML Characters</h2>
<p>To clean invalid characters, we can use the following regular expression. This basically removes any characters outside the allowed character range.</p><pre class="crayon-plain-tag">[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]</pre><p>
The above expression is sufficient for most cases, but it is not the best solution. <span style="box-sizing: border-box; margin: 0px; padding: 0px;">If you really want the most accurate expression <span style="box-sizing: border-box; margin: 0px; padding: 0px;">per the <a href="http://www.w3.org/TR/xml/#charsets" target="_blank" rel="noopener">XML Specs,</a> </span>use the expression below.</span> It can be <b>SLOW for large XML files</b>.</p><pre class="crayon-plain-tag">[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd]|([\ud800-\udbff](?![\udc00-\udfff]))|((?&lt;![\ud800-\udbff])[\udc00-\udfff])</pre><p>
<h2>Remove any characters</h2>
<p>If you don&#8217;t have a range of valid characters but you know a list of invalid characters, use the expression below (without the ^). For example, if you want to remove A, C, and E; then use the below</p><pre class="crayon-plain-tag">[ACE]

--OR-- Use hex codes

[\x41\x43\x45]</pre><p>
You can also use a range</p>
[0-9A-Za-z]
<h2>Step-By-Step Example</h2>
<ol>
<li>Download and install <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack from here.</a></li>
<li>Create a new SSIS Project.</li>
<li>Drag the <a href="//zappysys.com/products/ssis-powerpack/ssis-file-system-task-advanced/" target="_blank" rel="noopener">ZS Advanced File System Task</a> from the SSIS Toolbox to the control flow designer.</li>
<li>Double-click the task to edit its properties, as shown below. Enter the following expression for a Regular Expression.<br />
<pre class="crayon-plain-tag">[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]</pre>
</li>
<li>Save the package and execute. After you run the task, it will remove (replace with blank) any invalid character in your XML file.</li>
</ol>
<p>Here is the screenshot of the Task configuration.</p>
<div id="attachment_11598" style="width: 830px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/01/SSIS-Advanced-File-System-Task-Search-and-Replace-Option-Remove-invalid-XML-characters-using-Regex-Regular-Expression.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11598" class="size-full wp-image-11598" src="https://zappysys.com/blog/wp-content/uploads/2017/01/SSIS-Advanced-File-System-Task-Search-and-Replace-Option-Remove-invalid-XML-characters-using-Regex-Regular-Expression.png" alt="" width="820" height="595" srcset="https://zappysys.com/blog/wp-content/uploads/2017/01/SSIS-Advanced-File-System-Task-Search-and-Replace-Option-Remove-invalid-XML-characters-using-Regex-Regular-Expression.png 820w, https://zappysys.com/blog/wp-content/uploads/2017/01/SSIS-Advanced-File-System-Task-Search-and-Replace-Option-Remove-invalid-XML-characters-using-Regex-Regular-Expression-300x218.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/01/SSIS-Advanced-File-System-Task-Search-and-Replace-Option-Remove-invalid-XML-characters-using-Regex-Regular-Expression-768x557.png 768w" sizes="(max-width: 820px) 100vw, 820px" /></a><p id="caption-attachment-11598" class="wp-caption-text">SSIS Advanced File System Task &#8211; Search and Replace Option -Remove invalid XML characters using Regex (Regular Expression)</p></div>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/how-to-remove-invalid-characters-from-xml-using-ssis-and-regex/">How to remove invalid characters from XML using SSIS and Regex</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using SSIS Regex Parser Task for Extracting HTML Content</title>
		<link>https://zappysys.com/blog/using-ssis-regex-parser-task-extracting-html-content/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 26 Dec 2016 17:09:57 +0000</pubDate>
				<category><![CDATA[SSIS Regex Parser Task]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis regex parser task]]></category>
		<category><![CDATA[ssis rest api task]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=919</guid>

					<description><![CDATA[<p>Introduction In this post you will learn how to use FREE SSIS Regex Parser Task along with REST API Task to extract HTML content in few clicks. Scenario Assume that you want to search certain keywords from Bing or google and want to know how many pages found for that keyword. Url for search would [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/using-ssis-regex-parser-task-extracting-html-content/">Using SSIS Regex Parser Task for Extracting HTML Content</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis-regex-parser-task.png"><img loading="lazy" decoding="async" class="size-full wp-image-2974 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/03/ssis-regex-parser-task.png" alt="" width="100" height="100" /></a>In this post you will learn how to use FREE <a href="//zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regex Parser Task</a> along with <a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to extract HTML content in few clicks.</p>
<p>Scenario</p>
<p>Assume that you want to search certain keywords from Bing or google and want to know how many pages found for that keyword. Url for search would be something like http://www.bing.com/search?q=regex where regex is our search word.</p>
<p>When page is returned view source code of that page and you will find tag like below.</p><pre class="crayon-plain-tag">&lt;span class="sb_count" data-bm="4"&gt;21,00,000 results&lt;/span&gt;</pre><p>
What we want is number 21,00,000 using Regular expression pattern search.</p>
<h2>Step-By-Step : Extract HTML Tag value using Regex Expression</h2>
<ol>
<li>Download and Install <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> (It includes FREE <a href="//zappysys.com/products/ssis-powerpack/ssis-regex-parser-task/" target="_blank" rel="noopener">SSIS Regex Parser Task</a> )</li>
<li>Create new SSIS Package</li>
<li>Drag ZS REST API Task on Control flow designer from SSIS Toolbox</li>
<li>Double click to configure the task. Enter URL you like to fetch e.g. http://www.bing.com/search?q=regex</li>
<li>Click on Response Tab and check Save response option. Select Save to Variable. If needed create new variable.</li>
<li>Click Test (Scroll at the bottom to see html content)</li>
<li>Now drag ZS Regex Parser Task and connect with REST API Task</li>
<li>Select Variable which will hold HTML text you like to parse.</li>
<li>Enter following expression and map target to some Variable if you like to save extracted value. Below expression ends with {{0,1}} which means extract first match and 2nd group of that match (0 based Index). 2nd group of match will hold actual count of search result. If you omit {{x,y}} at the end then {{0,0}} is used.<br />
<pre class="crayon-plain-tag">\&lt;span\s*\w*\s*class="sb_count"\s*&gt;\s*(?&lt;p2&gt;[0-9,.]*){{0,1}}</pre>
See below screenshot</p>
<div id="attachment_920" style="width: 710px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-expression-extract-html-tag-value.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-920" class="wp-image-920" src="//zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-expression-extract-html-tag-value.png" alt="SSIS Regex Parser Task - Extract HTML Tag Value using Regular Expression" width="700" height="461" srcset="https://zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-expression-extract-html-tag-value.png 881w, https://zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-expression-extract-html-tag-value-300x198.png 300w" sizes="(max-width: 700px) 100vw, 700px" /></a><p id="caption-attachment-920" class="wp-caption-text">SSIS Regex Parser Task &#8211; Extract HTML Tag Value using Regular Expression</p></div></li>
<li>In the above step you can select Variable as Input or use placeholder in Direct string (e.g  {{Use::varHtml}} )</li>
<li> You can also connect ZS Logging task to show extracted value</li>
</ol>
<p>Here is final flow.</p>
<div id="attachment_921" style="width: 700px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-parse-example-download-page-extract-html-tag-value.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-921" class="size-full wp-image-921" src="//zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-parse-example-download-page-extract-html-tag-value.png" alt="SSIS Regular expression parsing example" width="690" height="406" srcset="https://zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-parse-example-download-page-extract-html-tag-value.png 690w, https://zappysys.com/blog/wp-content/uploads/2016/12/ssis-regex-parse-example-download-page-extract-html-tag-value-300x177.png 300w" sizes="(max-width: 690px) 100vw, 690px" /></a><p id="caption-attachment-921" class="wp-caption-text">SSIS Regular expression parsing example</p></div>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/using-ssis-regex-parser-task-extracting-html-content/">Using SSIS Regex Parser Task for Extracting HTML Content</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>
		<item>
		<title>JSONPath Expression Examples &#8211; JSON Cheatsheet (SSIS / ODBC)</title>
		<link>https://zappysys.com/blog/jsonpath-examples-expression-cheetsheet/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 23:17:00 +0000</pubDate>
				<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS Tips & How-Tos]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[jsonpath]]></category>
		<category><![CDATA[odbc]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=75</guid>

					<description><![CDATA[<p>What is JSONPath expression JSONPath expression is an expression language to filter JSON Data. Its a similar concept to XPath expression in XML but has limited features compared to XPath. If you are extracting data from REST API Services using SSIS JSON / XML Source or ODBC JSON / XML Driver then you will quickly realize [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/jsonpath-examples-expression-cheetsheet/">JSONPath Expression Examples &#8211; JSON Cheatsheet (SSIS / ODBC)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>What is JSONPath expression</h2>
<p style="text-align: left;"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/how-to-180x180.png"><img loading="lazy" decoding="async" class=" wp-image-2223 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2017/07/how-to-180x180.png" alt="" width="86" height="86" /></a><a href="https://goessner.net/articles/JsonPath/" target="_blank" rel="noopener">JSONPath</a> expression is an expression language to filter JSON Data. Its a similar concept to XPath expression in XML but has limited features compared to XPath. If you are extracting data from REST API Services using <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/">SSIS JSON / XML Source</a> or <a href="https://zappysys.com/products/odbc-powerpack/odbc-json-rest-api-driver/" target="_blank" rel="noopener">ODBC JSON / XML Driver</a> then you will quickly realize that it&#8217;s very important to extract nested data by navigating to a certain level.</p>
<h2></h2>
<h2></h2>
<p>&nbsp;</p>
<h2>Sample data for JSONPath expression</h2>
<p>All examples of JSONPath expression in this post will use the following sample JSON for reference.</p>
<div>
<pre class="crayon-plain-tag">{
  "store": {
    "books": [
      {
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95,
        "sections": ["s1", "s2", "s3"],
        "publicationDay": "2023-05-10"
      },
      {
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99,
        "sections": ["s4", "s1", "s3"],
        "publicationDay": "2022-08-10"
      },
      {
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99,
        "sections": ["s1"],
        "publicationDay": "1851-10-11"
      },
      {
        "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99,
        "sections": ["s8", "s9"],
        "publicationDay": "1954-07-12"
      }
    ],
    "time": {
      "starttime": "8:00",
      "endtime": "18:00"
    }
  }
}</pre>
</div>
<h2>JSONPath Examples</h2>
<pre class="crayon-plain-tag">//get all books for store
$.store.books[*]
                     
//get all sections from all books
$.store.books[*].sections[*]     

//get all authors of all books for store
$.store.books[*].author  
             
//get 3rd book record 
$.store.books[2]    

//get first 2 books from the top
$.store.books[:2]   

//get last 2 books
$.store.books[-2:]
  
//get all books where author attribute equals to 'sam'
$.store.books[?(@author=='Nigel Rees')] 

//get all documents / sub documents (any level) where author attribute equals to 'sam'
$..[?(@author=='Nigel Rees')] 

//get books where price is less than 10
$.store.books[?(@.price&lt;10)] 

//filter all books with tag
$.store.books[?(@.tag)]

//find all books which contains section s1 or s2 (Use of Logical operator OR ( || )
$.store.books[?(@.sections[*]=='s1' || @.sections[*]=='s2' )]

//find all books where first section is s1 and second section is s2 (Logical operator OR ( &amp;&amp; )
$.store.books[?(@.sections[0]=='s1' &amp;&amp; @.sections[1]=='s2' )]

// Find all books where the publication day is before 2000-01-01
$.store.books[?(@.publicationDay &lt; '2000-01-01')]</pre>
<h2>JSON Path &#8211; Using Regular Expressions (Regex)</h2>
<p>The new version of SSIS PowerPack and ODBC PowerPack Supports Regular expressions in the path. Learn more about Regular expressions <a href="https://zappysys.com/blog/using-regular-expressions-in-ssis/" target="_blank" rel="noopener">check this article</a></p><pre class="crayon-plain-tag">//Using Regular Expression: get all books where author attribute contains 'Nigel' or 'Waugh'
//Learn more about regular expressions here : https://zappysys.com/blog/using-regular-expressions-in-ssis/
$.store.books[?(@author=~ /Nigel|Waugh/  )] 

//Using Regular Expression: get all books where category is 'reference' OR author attribute contains 'Nigel' or 'Waugh'
$.store.books[?(@category=='reference' || @author=~ /Nigel|Waugh/ )] 

//Using Regular Expression: get all books where category is 'reference' AND author attribute contains 'Nigel' or 'Waugh'
$.store.books[?(@category=='reference' &amp;&amp; @author=~ /Nigel|Waugh/ )] 

//Using Regular Expression: get all books where author name either start with 'Nigel' (see ^ prefix) or ends with 'Waugh' (see $ suffix)
//Learn more about regular expressions here : https://zappysys.com/blog/using-regular-expressions-in-ssis/
$.store.books[?(@author=~ /^Nigel|Waugh$/  )] 

//Using Regular Expression: get all books where author name starts with 'Nigel'
//Learn more about regular expressions here : https://zappysys.com/blog/using-regular-expressions-in-ssis/
$.store.books[?(@author=~ /^Nigel/  )] 

//Using Regular Expression: get all books where author name ends with 'Waugh'
//Learn more about regular expressions here : https://zappysys.com/blog/using-regular-expressions-in-ssis/
$.store.books[?(@author=~ /Waugh$/  )]</pre><p>
<h2>JSON Path &#8211; Nested Scan for any level (double dots)</h2>
<p>Now lets look at example of below JSON. Assume that you like to extract information from all nested &#8220;<strong>children</strong>&#8221;  nodes (basically extract id and name of every child from any level).</p>
<p>You can use double dots without specifying parent heirarchy like below to scan recusrsivly.</p>
<pre class="crayon-plain-tag">$..children[*]</pre>
<div>
<pre class="crayon-plain-tag">{
  "children": [
    {
      "id": 1,
      "name": "c1",
      "children": [
        {
          "id": 2,
          "name": "c2",
          "children": [
            {
              "id": 3,
              "name": "c3",
              "children": [
                { "id": 4, "name": "c4" },
                { "id": 5, "name": "c5" }
              ]
            }
          ]
        }
      ]
    }
  ]
}</pre>
</div>
<p>For this you can write following JSON Path</p>
<pre class="crayon-plain-tag">$..children[*]</pre>
<p>OR (below to find all children where name is c1 or c2 or c3)</p>
<pre class="crayon-plain-tag">$..children[?(@name=~ /c1|c2|c3/ )]</pre>
<p>Here is an example of a JSON Driver in ODBC. The same expression can be used in SSIS too.</p>
<div id="attachment_11483" style="width: 835px" class="wp-caption alignleft"><a href="https://zappysys.com/blog/wp-content/uploads/2015/10/JSON-ODBC-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11483" class="wp-image-11483 size-full" src="https://zappysys.com/blog/wp-content/uploads/2015/10/JSON-ODBC-example.png" alt="ODBC JSON Driver - Using Filter with Regular Expressions / JSONPath" width="825" height="784" srcset="https://zappysys.com/blog/wp-content/uploads/2015/10/JSON-ODBC-example.png 825w, https://zappysys.com/blog/wp-content/uploads/2015/10/JSON-ODBC-example-300x285.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/10/JSON-ODBC-example-768x730.png 768w" sizes="(max-width: 825px) 100vw, 825px" /></a><p id="caption-attachment-11483" class="wp-caption-text">ODBC JSON Driver &#8211; Using Filter with Regular Expressions / JSONPath</p></div>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2></h2>
<h2>JSONPath for Root Objects in Array</h2>
<p>Now lets look at another pattern of JSON where your documents are on the first level rather than under some array property. Root filter only works if you have a version released after Dec-29-2021. Previous version didn&#8217;t support filtering on Root Array.</p>
<p><strong>Example JSON</strong></p><pre class="crayon-plain-tag">[
 { id:1 , color:'red'},
 { id:2 , color:'red'},
 { id:3 , color:'blue'},
 { id:4 , color:'green'}
]</pre><p>
<strong>Example JSON Path Filters</strong></p><pre class="crayon-plain-tag">$.[0]  //Extract first document
$..[?(@color=='red')]   //Recursive scan (any level) - Extract all documents where color=red use 2 dots after $ for filter</pre><p>
<strong>NOTE:</strong> using two dots after $ (e.g. <strong>$..[zzzz]</strong>) invokes nested scan so any level array will return documents, this may not be the acceptable case sometimes but if you want to filter the root array then this is the only way for now in ZappySys.</p>
<p>If you must not allow recursive scan then you can use the following two properties</p>
<p>EnableRawOutputModeSingleRow = true;<br />
RawOutputDataRowTemplate = &#8220;{data: [$1] }&#8221;  &#8211;where [$1] is replaced at runtime with Document Text you like to parse (can be static or URL response)</p>
<p>OR</p>
<p>Use functions in RawOutputDataRowTemplate if needed</p>
<p>RawOutputDataRowTemplate = &#8220;{data: &lt;&lt;[$1],FUN_BASE64DEC&gt;&gt;}&#8221;</p>
<p>The above will wrap around the actual JSON / XML you need to parse so now after this setting you can use JSONPath = $.data[?(@id==1)] to avoid two dots to prevent a recursive scan</p>
<p>The post <a href="https://zappysys.com/blog/jsonpath-examples-expression-cheetsheet/">JSONPath Expression Examples &#8211; JSON Cheatsheet (SSIS / ODBC)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
