<?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>SSIS CSV Generator Transform Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/category/ssis/components/ssis-csv-generator-transform/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/category/ssis/components/ssis-csv-generator-transform/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Wed, 19 Mar 2025 13:08:56 +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>SSIS CSV Generator Transform Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/category/ssis/components/ssis-csv-generator-transform/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to read YouTube API data in SSIS (Videos, Channels, Playlists)</title>
		<link>https://zappysys.com/blog/read-youtube-api-data-ssis-videos-channels-playlists/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 06 May 2019 18:06:07 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS CSV Generator Transform]]></category>
		<category><![CDATA[SSIS JSON Parser Transform]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS OAuth Connection]]></category>
		<category><![CDATA[SSIS REST API Task]]></category>
		<category><![CDATA[SSIS WEB API Destination]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[youtube]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=6894</guid>

					<description><![CDATA[<p>Introduction In last few articles we saw how to read data from various Google Services. In this article we will see how to read YouTube API data in SSIS. This blog mainly focus on SSIS approach but steps mentioned to call Google APIs can be useful for any developer regardless which programming language or toolset [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/read-youtube-api-data-ssis-videos-channels-playlists/">How to read YouTube API data in SSIS (Videos, Channels, Playlists)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>UPDATE:</strong> ZappySys has released a brand new <a href="https://zappysys.com/api/integration-hub/youtube-connector/">API Connector for YouTube</a> which makes it much simpler to <strong>Read/Write YouTube Data in SSIS</strong> compared to the steps listed in this article. You can still use steps from this article but if you are new to API or want to avoid learning curve with API then use newer approach.</p>
<p>Please visit <a href="https://zappysys.com/api/integration-hub/">this page to see all</a> Pre-Configured ready to use API connectors which you can use in <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-source/">SSIS API Source</a> / <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-destination/">SSIS API Destination</a> OR <a href="https://zappysys.com/products/odbc-powerpack/odbc-api-driver/">API ODBC Driver</a> (for non-SSIS Apps such as Excel, Power BI, Informatica).</p>
</div></div>
<a href="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-logo.png"><img decoding="async" class=" wp-image-6904 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-logo.png" alt="" width="100" height="100" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-logo.png 400w, https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-logo-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-logo-300x300.png 300w" sizes="(max-width: 100px) 100vw, 100px" /></a>In last <a href="https://zappysys.com/blog/category/google-api/">few articles</a> we saw how to read data from various Google Services. In this article we will see how to read YouTube API data in SSIS. This blog mainly focus on SSIS approach but steps mentioned to call Google APIs can be useful for any developer regardless which programming language or toolset you use.</p>
<p>&nbsp;</p>
<p>&nbsp;</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>Connect to YouTube API in SSIS (OAuth Connection)</h2>
<p>Very first step to call any Google API is to create an API project for Google Service and then enable APIs you like to call in Console. In our case we need to enable YouTube API.</p>
<p><a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Check this article</a> to learn how to create API Project and obtain Client ID and Client Secret to connect to YouTube API. For ease of use use Default Application provided by ZappySys but we still recommend using your own Custom Application  on OAuth Connection.</p>
<p>Before we try our first YouTube API example, we recommend you to get familiar with <a href="https://developers.google.com/youtube/v3/docs/" target="_blank" rel="noopener">YouTube API here</a>. Once you done with above steps you can perform the following steps to call YouTube API in SSIS.</p>
<ol>
<li>Open existing SSIS Project or Create new One in Visual Studio (i.e. SSDT)</li>
<li>Create a new SSIS Package. Right click in the Connection Manager Panel and click <strong>&#8220;New Connection&#8230;&#8221;</strong>.<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>When Dialog box opens select <strong>ZS-OAUTH</strong> connection type.
<div id="attachment_4724" style="width: 681px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/ssis-connection-managers-list-select-zs-oauth-connection-manager.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-4724" class="size-full wp-image-4724" src="https://zappysys.com/blog/wp-content/uploads/2018/08/ssis-connection-managers-list-select-zs-oauth-connection-manager.png" alt="SSIS Connection Maangers List: Select O-AUTH Connection Manager" width="671" height="549" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/ssis-connection-managers-list-select-zs-oauth-connection-manager.png 671w, https://zappysys.com/blog/wp-content/uploads/2018/08/ssis-connection-managers-list-select-zs-oauth-connection-manager-300x245.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></a><p id="caption-attachment-4724" class="wp-caption-text">SSIS Connection Managers List: Select O-AUTH Connection Manager</p></div></li>
<li>Once OAuth UI opens, Configure Google connection like below.
<ol>
<li>Select Service Type as <strong>Google</strong></li>
<li>You can select Default App for ease of use or Select Custom Application (Enter Client Id and Secret Obtained using <a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">these steps</a> )</li>
<li>In the Scope Enter below &#8211; One scope per line for calling correct YouTube API. Refer to <a href="https://developers.google.com/youtube/v3/docs/" target="_blank" rel="noopener">YouTube API documentation</a> incase you need extra permissions. For read only operation we just need below scopes. Last scope is only needed if you need to use <a href="https://developers.google.com/youtube/analytics/reference/reports/query" target="_blank" rel="noopener">YouTube Analytics Reports</a><br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/yt-analytics.readonly</pre>
</li>
</ol>
</li>
<li>Click Generate Token to obtain Refresh Token (You may see Login Prompt, and then Grant Permission Confirmation Screen)
<div id="attachment_6855" style="width: 930px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6855" class="size-full wp-image-6855" src="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token.png" alt="Connect to Google API using OAuth 2.0 (Youtube API Example)" width="920" height="1032" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token.png 920w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token-267x300.png 267w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token-768x861.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-oauth-connection-manager-generate-access-token-913x1024.png 913w" sizes="(max-width: 920px) 100vw, 920px" /></a><p id="caption-attachment-6855" class="wp-caption-text">Connect to Google API using OAuth 2.0 (YouTube API Example)</p></div></li>
<li>Click OK to save UI.</li>
</ol>
<h2>Call YouTube REST API Example</h2>
<p>Now lets look at how to call YouTube API <a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a> this task is more suitable to call GET, POST, DELETE, PUT requests without parsing data in Rows and Columns. If you need to parse data and load into Database table then see next section (Use JSON Source)</p>
<ol>
<li>From SSIS Toolbox look for items starting with “ZS”. Drag and Drop <b>[ZS Rest API Task]</b> to Designer Surface.<br />
<img decoding="async" class="figureimage" title="SSIS REST Api Web Service Task - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/rest-api-task/ssis-rest-api-web-service-task-drag.png" alt="SSIS REST Api Task - Drag and Drop" /></li>
<li>Double click it to configure like below.
<ol>
<li>Select URL From Connection option</li>
<li>Select OAuth connection created in previous section.</li>
<li>Enter URL like below (For example <a href="https://developers.google.com/youtube/v3/docs/playlists/list" target="_blank" rel="noopener">get all playlists</a>). Replace xxxxxxxxxxx with your own channel ID (Its usually found in URL when you visit Youtube Channel Homepage)<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/playlists?part=snippet,id&amp;channelId=xxxxxxxxxxxxx</pre>
</li>
<li>Click Test Request Button</li>
</ol>
</li>
<li>Here is how it looks like
<div id="attachment_6896" style="width: 854px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-call-youtube-api-with-dynamic-url.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6896" class="size-full wp-image-6896" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-call-youtube-api-with-dynamic-url.png" alt="Call Youtube API in SSIS Example (Dynamic URL)" width="844" height="640" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-call-youtube-api-with-dynamic-url.png 844w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-call-youtube-api-with-dynamic-url-300x227.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-call-youtube-api-with-dynamic-url-768x582.png 768w" sizes="(max-width: 844px) 100vw, 844px" /></a><p id="caption-attachment-6896" class="wp-caption-text">Call Youtube API in SSIS Example (Dynamic URL)</p></div></li>
</ol>
<p>That&#8217;s it we have successfully configured Connection for YouTube API in SSIS. In the next section we will see how to use this connection and read various data from YouTube API.</p>
<h2>Read YouTube Playlists in SSIS</h2>
<p>Once we done creating OAuth Connection Manager we can move forward to read YouTube data inside Data Flow.</p>
<p>Configure SSIS JSON / REST API Source</p>
<ol>
<li>Now, Drag and Drop SSIS <b>Data Flow Task</b> 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 Data Flow task to see Data Flow designer surface.</li>
<li>From the SSIS toolbox drag and drop JSON Source on the dataflow designer surface.<br />
<img decoding="async" class="figureimage" title="SSIS JSON Source - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-source/ssis-json-source-adapter-drag.png" alt="SSIS JSON Source - Drag and Drop" /></li>
<li>Double click JSON Source and enter URL as below (Use variable or Hardcode Channel Id). maxResults controls how many rows you want to get in each response. Rep<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/playlists?part=snippet,id&amp;maxResults=50&amp;channelId={{User::varChannelId}}
--OR-- 
https://www.googleapis.com/youtube/v3/playlists?part=snippet,id&amp;maxResults=50&amp;channelId=xxxxxxxxxxxxxxxxxxxxxx</pre>
</li>
<li>Check Use Credentials and select existing OAuth connection or Create New one</li>
<li>Select Array Filter (Items node) or type <pre class="crayon-plain-tag">$.items[*]</pre>  as below.
<div id="attachment_6900" style="width: 857px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-get-playlists.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6900" class="size-full wp-image-6900" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-get-playlists.png" alt="Get Playlists for YouTube Channel" width="847" height="738" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-get-playlists.png 847w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-get-playlists-300x261.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-get-playlists-768x669.png 768w" sizes="(max-width: 847px) 100vw, 847px" /></a><p id="caption-attachment-6900" class="wp-caption-text">Get Playlists for YouTube Channel</p></div></li>
<li>That&#8217;s it you can now Click <strong>Preview</strong> to see sample data. In the next section we will configure Pagination to read all records if you have more than 100 rows.</li>
</ol>
<h3>Configure YouTube REST API Pagination</h3>
<p>Most REST APIs dont return data in one big response. So you have to make sure you implement looping / pagination to read more records. Luckily ZappySys supports <a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/">many different Pagination Settings</a>. Here is how to configure YouTube REST API Pagination.</p>
<ol>
<li>Go to Pagination Tab found on JSON Source and select following 3 settings</li>
<li>Select Pagination Mode as <pre class="crayon-plain-tag">Response Attribute Mode</pre></li>
<li>Enter Next Link as <pre class="crayon-plain-tag">$.nextPageToken</pre></li>
<li>Enter Suffix for Next URL as <pre class="crayon-plain-tag">&amp;pageToken=&lt;%nextlink%&gt;</pre></li>
</ol>
<div id="attachment_6899" style="width: 555px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-rest-api-pagination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6899" class="size-full wp-image-6899" src="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-rest-api-pagination.png" alt="YouTube REST API Pagination Settings" width="545" height="246" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-rest-api-pagination.png 545w, https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-rest-api-pagination-300x135.png 300w" sizes="(max-width: 545px) 100vw, 545px" /></a><p id="caption-attachment-6899" class="wp-caption-text">YouTube REST API Pagination Settings</p></div>
<h2>Read YouTube Playlist Videos in SSIS</h2>
<p>So in previous section we saw simple API call to read all playlists from YouTube. Now lets see how to get information about <a href="https://developers.google.com/youtube/v3/docs/playlistItems/list" target="_blank" rel="noopener">Playlist Videos</a>.</p>
<p>For that everything should remain same as previous section except change URL as below. Where xxxxxxxxxxxxxxxxxxxxx is your Playlist ID obtained from Previous Call.</p><pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,id&amp;maxResults=50&amp;playlistId=xxxxxxxxxxxxxxxxxxxxx</pre><p>
<h2>Get all Videos for YouTube Channel</h2>
<p>If you want to get all video name and ID for specific channel then use below URL. Click here to <a href="https://developers.google.com/youtube/v3/docs/search/list" target="_blank" rel="noopener">read more</a>. Replace xxxxxxxxxxxxxxxxxxx with your Channel ID.</p><pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/search?channelId=xxxxxxxxxxxxxxxxxxx&amp;part=snippet,id&amp;order=date&amp;maxResults=50</pre><p>
&nbsp;</p>
<h2>Read YouTube Video Views, Likes, Dislikes (Extended Videos)</h2>
<p>Another common request from YouTube API is get Video Information such as Views, Likes, Dislikes, Comment Count etc. For that you can <a href="https://developers.google.com/youtube/v3/docs/videos/list" target="_blank" rel="noopener">use this api</a> . However the issue is this endpoint requires you to pass Comma separated Ids of Video. You can only pass 25 Ids in one requests so if you have 200 videos for which you need to get information then you have to make 8 requests (25 Ids in each Request). In below screenshot you can see we used <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Fiddler to debug web requests</a>.</p>
<p>So here is how high level process to fetch extended information for all Videos in your channel. Full <a href="https://zappysys.com/blog/wp-content/uploads/2019/05/Google_Youtube_API_Demo.zip">SSIS Package is attached here (SSIS 2012 Format)</a>.</p>
<ol>
<li>Get all videos for your channel by calling (Assuming you will paginate in below request.<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/search?channelId=xxxxxxxxxxxxxxxxxxx&amp;part=snippet,id&amp;order=date&amp;maxResults=50</pre>
</li>
<li>Build Video Id groups for 25 Ids from above result and submit requests. For example if above request returns 200 Videos then your request to fetch extended information may look like below.<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&amp;id=ID1,ID2,ID3........ID25
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&amp;id=ID26,ID27,ID28........ID50
........
........
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&amp;id=ID176,ID177,ID178........ID200</pre>
</li>
<li>Parse response coming from each Request Above&#8230;. Each Response will give you details about 25 videos you requesting.</li>
</ol>
<p>Here is the flow of our complete data flow to read extended information for all videos. You can read extended information one by one too but it wont be good idea if you have many videos.</p>
<p>We have used Following Components to achieve Bulk Mode</p>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source (REST API Source)</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-parser-transform/" target="_blank" rel="noopener">CSV Parser Transform</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a></li>
</ul>
<div id="attachment_6901" style="width: 1306px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6901" class="size-full wp-image-6901" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes.png" alt="Get YouTube Video View Clicks, Likes, Dislikes (Bulk Mode for all videos)" width="1296" height="823" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes.png 1296w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes-300x191.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes-768x488.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-get-youtube-video-view-count-likes-dislikes-1024x650.png 1024w" sizes="(max-width: 1296px) 100vw, 1296px" /></a><p id="caption-attachment-6901" class="wp-caption-text">Get YouTube Video View Clicks, Likes, Dislikes (Bulk Mode for all videos)</p></div>
<h2>Read data from YouTube Analytics / Reporting API (Metrics, Dimensions Report)</h2>
<p>So far we have seen basic YouTube APIs to extract your Channel information. However there is another very powerful API endpoint to query custom reports from YouTube. Check <a href="https://developers.google.com/youtube/analytics/reference/reports/query" target="_blank" rel="noopener">this YouTube Analytics API endpoint</a>. In this section we will learn how to extract useful information from YouTube using Analytics API.</p>
<h3>Step-By-Step</h3>
<p>Let&#8217;s look at an example to read total views, estimated watch time, average view duration and some other metrics by date for channel you have access.</p>
<ol>
<li>Go to Data Flow, Drag ZS JSON Source from SSIS Toolbox</li>
<li>Double click to configure.</li>
<li>Check Use Credentials. Select OAuth connection we created in previous section.</li>
<li>In the URL field, Enter Below Sample URL. Change Parameters as per your need or leave it default.<br />
For example:<br />
<strong>ids=channel==MINE</strong>   (where MINE can be replaced by other channel id or keep it as MINE to get data for your own channel)<br />
<strong>metrics</strong> (can be changed from any <a href="https://developers.google.com/youtube/analytics/metrics" target="_blank" rel="noopener">valid list here</a>)<br />
<strong>dimensions</strong> (can be changed to any valid <a href="https://developers.google.com/youtube/analytics/dimensions" target="_blank" rel="noopener">list from here</a>)<br />
<strong>startDate</strong> (Must be YYYY-MM-DD format)<br />
<strong>endDate</strong> (Must be YYYY-MM-DD format)<br />
<pre class="crayon-plain-tag">https://youtubeanalytics.googleapis.com/v2/reports?ids=channel==MINE&amp;metrics=views,estimatedMinutesWatched,averageViewDuration,averageViewPercentage,subscribersGained&amp;dimensions=day&amp;startDate=2019-03-01&amp;endDate=2019-04-01</pre>
</li>
<li>Change Filter to <pre class="crayon-plain-tag">$.rows[*]</pre></li>
<li>Go to <strong>2D Array Transform</strong> tab.<br />
Select Method as <pre class="crayon-plain-tag">Simple 2-dimensional array</pre>
EnterColumn Filter as  <pre class="crayon-plain-tag">$.columnHeaders[*].name</pre>
<div id="attachment_6909" style="width: 906px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/advanced-transform-youtube-analytics-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6909" class="size-full wp-image-6909" src="https://zappysys.com/blog/wp-content/uploads/2019/05/advanced-transform-youtube-analytics-api.png" alt="YouTube Analytics API Advanced Transformation" width="896" height="270" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/advanced-transform-youtube-analytics-api.png 896w, https://zappysys.com/blog/wp-content/uploads/2019/05/advanced-transform-youtube-analytics-api-300x90.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/advanced-transform-youtube-analytics-api-768x231.png 768w" sizes="(max-width: 896px) 100vw, 896px" /></a><p id="caption-attachment-6909" class="wp-caption-text">YouTube Analytics API Advanced Transformation</p></div></li>
<li>That&#8217;s it now Preview your data. See below over all steps.
<div id="attachment_6910" style="width: 978px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-analytics-report-api-dimensions-metrics.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6910" class="size-full wp-image-6910" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-analytics-report-api-dimensions-metrics.png" alt="Read data from YouTube Analytics API (Custom Reports using Dimensions, Metrics Query)" width="968" height="741" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-analytics-report-api-dimensions-metrics.png 968w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-analytics-report-api-dimensions-metrics-300x230.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-youtube-analytics-report-api-dimensions-metrics-768x588.png 768w" sizes="(max-width: 968px) 100vw, 968px" /></a><p id="caption-attachment-6910" class="wp-caption-text">Read data from YouTube Analytics API (Custom Reports using Dimensions, Metrics Query)</p></div></li>
</ol>
<h3>Build YouTube Analytics / Reporting API Query (API Playground)</h3>
<p>With Analytics API You can extract many interesting data. You can use Test Tool found <a href="https://developers.google.com/youtube/analytics/reference/reports/query" target="_blank" rel="noopener">on this page to build</a> some interesting queries. Scroll to <strong>Common Use Cases</strong> section on that link. On the right side you can select Credentials Type as OAuth and click Execute.</p>
<p><a href="https://developers.google.com/youtube/analytics/reference/reports/query" target="_blank" rel="noopener">https://developers.google.com/youtube/analytics/reference/reports/query</a></p>
<div id="attachment_6911" style="width: 944px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-analytics-api-explorer-test-query-builder.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6911" class="size-full wp-image-6911" src="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-analytics-api-explorer-test-query-builder.jpg" alt="YouTube Analytics / Reporting API Explorer (Testing API Calls)" width="934" height="688" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-analytics-api-explorer-test-query-builder.jpg 934w, https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-analytics-api-explorer-test-query-builder-300x221.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/youtube-analytics-api-explorer-test-query-builder-768x566.jpg 768w" sizes="(max-width: 934px) 100vw, 934px" /></a><p id="caption-attachment-6911" class="wp-caption-text">YouTube Analytics / Reporting API Explorer (Testing API Calls)</p></div>
<h2>Loading YouTube API Data into SQL Server</h2>
<div class="content_block" id="custom_post_widget-5617"><p>ZappySys SSIS PowerPack makes it easy to load data from various sources such as REST, SOAP, JSON, XML, CSV or from other source into SQL Server, or PostgreSQL, or Amazon Redshift, or other  targets. The <strong>Upsert Destination</strong> component allows you to automatically insert new records and update existing ones based on key columns. Below are the detailed steps to configure it.</p>
<h3>Step 1: Add Upsert Destination to Data Flow</h3>
<ol>
<li>Drag and drop the <strong>Upsert Destination</strong> component from the SSIS Toolbox.</li>
<li>Connect your source component (e.g., JSON / REST / Other Source) to the Upsert Destination.</li>
</ol>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2017/08/ssis-data-flow-drag-drop-upsert-destination.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2017/08/ssis-data-flow-drag-drop-upsert-destination.png" /></a>
<p class="wp-caption-text">SSIS - Data Flow - Drang and Drop Upsert Destination Component</p>
</div>
<h3>Step 2: Configure Target Connection</h3>
<ol>
<li>Double-click the <strong>Upsert Destination</strong> component to open the configuration window.</li>
<li>Under <strong>Connection</strong>, select an existing target connection or click <strong>NEW</strong> to create a new connection.
<ul>
<li>Example: SQL Server, or PostgreSQL, or Amazon Redshift.</li>
</ul>
</li>
</ol>
<h3>Step 3: Select or Create Target Table</h3>
<ol>
<li>In the <strong>Target Table</strong> dropdown, select the table where you want to load data.</li>
<li>Optionally, click <strong>NEW</strong> to create a new table based on the source columns.</li>
</ol>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-configuration.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-configuration.png" /></a>
<p class="wp-caption-text">Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS</p>
</div>
<h3>Step 4: Map Columns</h3>
<ol>
<li>Go to the <strong>Mappings</strong> tab.</li>
<li>Click <strong>Auto Map</strong> to map source columns to target columns by name.</li>
<li>Ensure you <strong>check the Primary key column(s)</strong> that will determine whether a record is inserted or updated.</li>
<li>You can manually adjust the mappings if necessary.</li>
</ol>
 <div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-key.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-key.png" /></a>
<p class="wp-caption-text">SSIS Upsert Destination - Columns Mappings</p>
</div>
<h3>Step 5: Save Settings</h3>
<ul>
<li>Click <strong>OK</strong> to save the Upsert Destination configuration.</li>
</ul>
<h3>Step 6: Optional: Add Logging or Analysis</h3>
<ul>
<li>You may add extra destination components to log the number of inserted vs. updated records for monitoring or auditing purposes.</li>
</ul>
<h3>Step 7: Execute the Package</h3>
<ul>
<li>Run your SSIS package and verify that the data is correctly inserted and updated in the target table.</li>
</ul>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-upsert-destination-execute.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-upsert-destination-execute.png" /></a>
<p class="wp-caption-text">SSIS Upsert Destination Execution</p>
</div></div>
<h2>Download Sample SSIS Package</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/Google_Youtube_API_Demo.zip">SSIS Package is attached here (SSIS 2012 Format)</a>.</p>
<h2>Conclusion</h2>
<p>In this article we saw how to extract information from REST API such as YouTube REST API using OAuth 2.0. We also learned techniques like Pagination, JSON Parsing, Request Batching using multiple components to achieve full scale API integration. To explore many other scenarios not discussed in this article download <a href="https://zappysys.com/products/ssis-powerpack/">SSIS PowerPack from here (includes 70+ Components)</a>.</p>
<p>The post <a href="https://zappysys.com/blog/read-youtube-api-data-ssis-videos-channels-playlists/">How to read YouTube API data in SSIS (Videos, Channels, Playlists)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to batch REST API requests in SSIS (Bulk Operation)</title>
		<link>https://zappysys.com/blog/batch-rest-api-requests-ssis-bulk-operation/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Wed, 06 Feb 2019 21:32:43 +0000</pubDate>
				<category><![CDATA[SSIS CSV Generator Transform]]></category>
		<category><![CDATA[SSIS JSON Generator Transform]]></category>
		<category><![CDATA[SSIS Script Component]]></category>
		<category><![CDATA[SSIS WEB API Destination]]></category>
		<category><![CDATA[SSIS XML Generator Transform]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=6305</guid>

					<description><![CDATA[<p>Introduction In our previous article we saw how to POST data to REST API using few different ways. Now let&#8217;s go one step further and discuss another common scenario to batch REST API requests in SSIS. For efficient data transfer many API provides you to submit multiple records in a single request. In this article [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/batch-rest-api-requests-ssis-bulk-operation/">How to batch REST API requests in SSIS (Bulk Operation)</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 article we saw <a href="https://zappysys.com/blog/http-post-in-ssis-send-data-to-web-api-url-json-xml/" target="_blank" rel="noopener">how to POST data to REST API</a> using few different ways. Now let&#8217;s go one step further and discuss another common scenario to batch REST API requests in SSIS. For efficient data transfer many API provides you to submit multiple records in a single request. In this article we will look at few ways to batch our requests using <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">SSIS JSON Generator Transform</a> and  <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">SSIS Web API destination</a>.</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>Method 1 &#8211; Batch records using SSIS JSON / XML Generator Transform</h2>
<p>First let&#8217;s look at common way to group multiple records and generate single JSON or XML document for desired batch size. We will also see another technique where you can assign Unique BatchID to each document.</p>
<p>For example below screenshot shows how to product one JSON document for every 10 input rows. We have also use BatchID column on the root level. This will use use BatchID from first row of that batch. You can use <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-generator-transform/" target="_blank" rel="noopener">XML Generator Transform</a> if you like to produce XML Document rather than JSON.</p>
<p>To generate Unique BatchID you can use function like newid() in SQL Server.</p><pre class="crayon-plain-tag">SELECT newid() as BatchID,CustomerID,CompanyName FROM Customers</pre><p>
<div id="attachment_6306" style="width: 1115px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6306" class="size-full wp-image-6306" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting.png" alt="Using SSIS JSON Generator Transform with Batch Option (Multiple Records in a single document)" width="1105" height="865" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting.png 1105w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting-300x235.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting-768x601.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting-1024x802.png 1024w" sizes="(max-width: 1105px) 100vw, 1105px" /></a><p id="caption-attachment-6306" class="wp-caption-text">Using SSIS JSON Generator Transform with Batch Option (Multiple Records in a single document)</p></div>
<p>&nbsp;</p>
<p>Here if full flow to batch your JSON Requests and Submit to REST API.</p>
<div id="attachment_6307" style="width: 671px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-post-data-rest-api-in-batch.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6307" class="size-full wp-image-6307" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-post-data-rest-api-in-batch.png" alt="POST data to REST API in Bulk Mode (Batch multiple rows)" width="661" height="785" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-post-data-rest-api-in-batch.png 661w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-post-data-rest-api-in-batch-253x300.png 253w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-6307" class="wp-caption-text">POST data to REST API in Bulk Mode (Batch multiple rows)</p></div>
<p>&nbsp;</p>
<h2>Method 2 &#8211; Using SSIS Web API destination Batch Mode with Header / Footer</h2>
<p>Another method of batching is use Web API destination and turn on Batch mode.  You can <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">use Fiddler</a> to debug your web requests incase you are not sure how its generating and sending POST requests after this setting.</p>
<div id="attachment_2616" style="width: 919px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/02/ssis-call-smartsheet-rest-api-post-bulk-mode-web-api-destination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2616" class="size-full wp-image-2616" src="https://zappysys.com/blog/wp-content/uploads/2018/02/ssis-call-smartsheet-rest-api-post-bulk-mode-web-api-destination.png" alt="Configure SSIS Web API Destination for Bulk API call (Smartsheet REST API - Insert multiple rows)" width="909" height="445" srcset="https://zappysys.com/blog/wp-content/uploads/2018/02/ssis-call-smartsheet-rest-api-post-bulk-mode-web-api-destination.png 909w, https://zappysys.com/blog/wp-content/uploads/2018/02/ssis-call-smartsheet-rest-api-post-bulk-mode-web-api-destination-300x147.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/02/ssis-call-smartsheet-rest-api-post-bulk-mode-web-api-destination-768x376.png 768w" sizes="(max-width: 909px) 100vw, 909px" /></a><p id="caption-attachment-2616" class="wp-caption-text">Configure SSIS Web API Destination for Bulk API call (Insert multiple rows)</p></div>
<h2>Method 3 &#8211; Batch CSV records using CSV Generator Transform</h2>
<p>So far we looked at how to batch JSON and XML format. Now let&#8217;s look at scenario where you have to POST CSV formatted data to REST API endpoint.</p>
<p>Assume that you have an API endpoint where you can submit data in multiple batches. Also you have few additional requirements</p>
<ol>
<li>First row of First batch must have column names (any other batch must not contains CSV Header)</li>
<li>In each Batch we want to submit maximum 5 rows as per API call</li>
<li>Each batch must contain Unique Batch Number in URL</li>
</ol>
<p>Here is high level flow.</p>
<div id="attachment_6333" style="width: 1148px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6333" class="size-full wp-image-6333" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting.png" alt="Generate CSV using Batch Setting , Send data to REST API in multiple batches, Debug REST API in Fiddler" width="1138" height="508" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting.png 1138w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting-300x134.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting-768x343.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-csv-using-output-in-batch-setting-1024x457.png 1024w" sizes="(max-width: 1138px) 100vw, 1138px" /></a><p id="caption-attachment-6333" class="wp-caption-text">Generate CSV using Batch Setting , Send data to REST API in multiple batches, Debug REST API in Fiddler</p></div>
<h3>Include CSV Header in First Batch Only</h3>
<p>Now let&#8217;s break down the problem and find out how to do. First problem is we need to include CSV Header only in First batch. To achieve this we use old school trick where we output column names as data row&#8230; and when we generate CSV in the next section we will turn off Column Headers option.</p>
<p>If you are consuming records from SQL Server or any other RDBMS you can write following style source query. If you don&#8217;t use relational source then use native UNION Transform in SSIS.</p><pre class="crayon-plain-tag">select 'CustomerID' as Column1, 'OrderID' as Column2
UNION ALL
select top 12 cast(CustomerID as varchar(1000)), cast(OrderID as varchar(1000)) from Invoices</pre><p>
<h3>Batch records and output CSV data</h3>
<p>Now next step would be to generate CSV data but in batches&#8230; so in our example we have to output size of 5 rows per batch. For this perform the following steps</p>
<ol>
<li>Drag ZS CSV Generator Transform (Included in <strong>v2.8</strong> and Higher)</li>
<li>Connect source to CSV Generator Transform</li>
<li>Now before we edit in UI mode, <strong>right click</strong> and select <strong>Properties</strong>. Change following 3 properties  (You can also change QuoteAroundValue and Dimiliter if needed). In future version batch setting will be visible in UI mode too.
<ol>
<li>ArrayBatchSize  = yourbatchsize (in our case it was just 5 rows per batch)</li>
<li>OutputMode = SingleFileFormat</li>
<li>FirstRowsHasColumnNames  =False</li>
</ol>
</li>
<li>Now double click to configure ZS Generator Output</li>
<li>Right click on Mappings folder node and Add Elements &gt; Select Multiple Columns  &gt; Check columns you like to output</li>
<li>Click OK to Save UI</li>
</ol>
<div id="attachment_6336" style="width: 611px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-csv-generator-output-data-in-batch.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6336" class="size-full wp-image-6336" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-csv-generator-output-data-in-batch.png" alt="Generate CSV data in SSIS (Batch Output Setting)" width="601" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-csv-generator-output-data-in-batch.png 601w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-csv-generator-output-data-in-batch-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-csv-generator-output-data-in-batch-300x300.png 300w" sizes="(max-width: 601px) 100vw, 601px" /></a><p id="caption-attachment-6336" class="wp-caption-text">Generate CSV data in SSIS (Batch Output Setting)</p></div>
<h3>Generate unique URL with Batch using Script Component</h3>
<p>Now next task we have to achieve is generate Unique Batch Number. Put that Batch ID in URL like below&#8230;</p><pre class="crayon-plain-tag">http://httpbin.org/post?batch=0
http://httpbin.org/post?batch=1
http://httpbin.org/post?batch=2
.....</pre><p>
<ol>
<li>For this drag SSIS Script Component and select Transformation Mode</li>
<li>Now go to <strong>Inputs and Outputs</strong> tab &gt; Select <strong>Output Columns</strong> &gt; Click <strong>Add Column</strong> &gt; Name it as <strong>URL</strong> &gt; Configure <strong>DataType</strong> as <strong>DT_WSTR</strong> , <strong>Length</strong> = 500</li>
<li>Now got Script Tab and Click Edit. Remove old code and enter following code (Assuming You selected C#). This code will generate new URL with Unique batch ID each time. You can use this same technique to generate Unique row number too (in that case rather than DT_WSTR type you can use DT_I4 type)</p><pre class="crayon-plain-tag">[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
    private static int _batch;
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        Row.Url = string.Format("http://httpbin.org/post?batch={0}",_batch);
        //If you have to send GUID rather than Integer for Batch ID then use below code
        //Row.Url = string.Format("http://httpbin.org/post?batch={0}",System.Guid.NewGuid());

        _batch = _batch+1;
    }
}</pre><p>
</li>
<li>Click OK to Save script.</li>
</ol>
<div id="attachment_6334" style="width: 681px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-script-component-unique-row-number-output-new-column.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6334" class="size-full wp-image-6334" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-script-component-unique-row-number-output-new-column.png" alt="Output Unique URL or Number using SSIS Script Transform" width="671" height="768" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-script-component-unique-row-number-output-new-column.png 671w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-script-component-unique-row-number-output-new-column-262x300.png 262w" sizes="(max-width: 671px) 100vw, 671px" /></a><p id="caption-attachment-6334" class="wp-caption-text">Output Unique URL or Number using SSIS Script Transform</p></div>
<h3>Configure Web API Destination to POST CSV Data</h3>
<p>Now final step is to configure SSIS Web API Destination to POST CSV data to API.</p>
<ol>
<li>Drag ZS Web API Destination and connect Source Transform to Web API destination.</li>
<li>Double click to configure</li>
<li>Select Connection Manager</li>
<li>Once connection setup, select Input Column for URL ( This will be same column from Script Transform)</li>
<li>Select column for Body (e.g. ZS_CSV_OUT)</li>
<li>Click OK to save</li>
</ol>
<div id="attachment_6335" style="width: 739px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-configure-web-api-destination-post-csv-data-in-batch.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6335" class="size-full wp-image-6335" src="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-configure-web-api-destination-post-csv-data-in-batch.png" alt="POST data to REST API in multiple batches using SSIS Web API destination" width="729" height="764" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-configure-web-api-destination-post-csv-data-in-batch.png 729w, https://zappysys.com/blog/wp-content/uploads/2019/02/ssis-configure-web-api-destination-post-csv-data-in-batch-286x300.png 286w" sizes="(max-width: 729px) 100vw, 729px" /></a><p id="caption-attachment-6335" class="wp-caption-text">POST data to REST API in multiple batches using SSIS Web API destination</p></div>
<h2>Debug Web API Requests using Fiddler</h2>
<p>Now we ready to run entire flow. Once you execute data flow, observe Input rows before CSV Generator Transform and after. CSV Generator transform must produce less rows before we now grouping multiple rows in a single batch.</p>
<p>Another important aspect to play with API request is to debug it, We recommend you to to look at <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">this article about using Fiddler to debug web requests</a>.</p>
<h2>Download Sample Package</h2>
<p>Here is the <a href="https://zappysys.com/blog/wp-content/uploads/2019/02/RestAPI_Batch.zip">Sample SSIS Package (2012 format) &#8211; Rest API_Batching</a></p>
<h2>Conclusion</h2>
<p>In this post, we saw how easy it is to handle complex REST API  / CSV /JSON / XML operations in SSIS. We configured REST API POST Operation using Batching Method. Hope this post helps you to achieve your API integration without coding.  Feel free to <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">download SSIS PowerPack</a> and try many other components not discussed in this article.</p>
<p>The post <a href="https://zappysys.com/blog/batch-rest-api-requests-ssis-bulk-operation/">How to batch REST API requests in SSIS (Bulk Operation)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
