<?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>Google API Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/category/google-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/category/google-api/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 06 Nov 2025 21:43:40 +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>Google API Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/category/google-api/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to download files from Google Drive using SSIS</title>
		<link>https://zappysys.com/blog/download-files-google-drive-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sun, 05 Nov 2023 10:28:32 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[SSIS API Source]]></category>
		<category><![CDATA[SSIS Components]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[Google APIs]]></category>
		<category><![CDATA[Google Drive]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS API Destination]]></category>
		<category><![CDATA[SSIS Google Drive Connector]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=10649</guid>

					<description><![CDATA[<p>Introduction In today&#8217;s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you&#8217;re a user of SQL Server Integration Services (SSIS) and looking to integrate Google Drive into your data workflow, you&#8217;re in luck. ZappySys SSIS PowerPack offers a powerful Google Drive Connector that [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/download-files-google-drive-using-ssis/">How to download files from Google Drive using 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/2023/11/google_drive_logo.png"><img loading="lazy" decoding="async" class="alignleft wp-image-11097" src="https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-150x150.png" alt="" width="106" height="100" srcset="https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-300x284.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-768x727.png 768w, https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo.png 980w" sizes="(max-width: 106px) 100vw, 106px" /></a>In today&#8217;s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you&#8217;re a user of SQL Server Integration Services (SSIS) and looking to integrate Google Drive into your data workflow, you&#8217;re in luck. ZappySys SSIS PowerPack offers a powerful <a href="https://zappysys.com/api/integration-hub/google-drive-connector/">Google Drive Connector</a> that makes downloading files from Google Drive a breeze. In this guide, we&#8217;ll walk you through the process of downloading files from Google Drive using SSIS and the <a href="https://zappysys.com/api/integration-hub/google-drive-connector/ssis">ZappySys SSIS PowerPack Google Drive Connector</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>Download files from Google Drive with SSIS:</h2>
<p>In this section, we will learn how to configure and use Google Drive Connector in the API Source &amp; API Destination to download files from Google Drive.</p>
<ol>
<li>Begin with opening Visual Studio and Creating a New Project.</li>
<li>Select Integration Service Project and in the new project window set the appropriate name and location for the project. Click OK.</li>
<li>In the new SSIS project screen you will find the following:
<ol style="list-style-type: lower-alpha;">
<li>SSIS ToolBox on the left sidebar</li>
<li>Solution Explorer and Property Window on the right bar</li>
<li>Control flow, data flow, event Handlers, Package Explorer in tab windows</li>
<li>Connection Manager Window at the bottom</li>
</ol>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox.png">-`<img loading="lazy" decoding="async" class="alignnone wp-image-10258" src="https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-1024x653.png" alt="zappysys ssis project with toolbox" width="700" height="447" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-1024x653.png 1024w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-300x191.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-768x490.png 768w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox.png 1287w" sizes="(max-width: 700px) 100vw, 700px" /></a><br />
<div class="su-note"  style="border-color:#e5dd9d;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:#fff7b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE</strong>: If you don&#8217;t see ZappySys SSIS PowerPack Task or Components in the SSIS Toolbox, please refer to <a href="https://zappysys.zendesk.com/hc/en-us/articles/115004935754-I-don-t-see-PowerPack-components-in-SSIS-Toolbox">this help link</a>.</div></div></li>
<li>Now, Drag and Drop the SSIS Data Flow Task from the SSIS Toolbox. Double-click on the Data Flow Task to see the Data Flow Designer.<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10260" src="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png" alt="" width="460" height="155" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png 460w, https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task-300x101.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></a></li>
<li>From the SSIS toolbox drag and drop API Source (Predefined Templates) on the data flow designer surface, and double-click on it to edit it:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10262" src="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg" alt="" width="659" height="292" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg 659w, https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop-300x133.jpg 300w" sizes="(max-width: 659px) 100vw, 659px" /></a></li>
<li>Select <strong>New Connection</strong> to create a new connection:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10263" src="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png" alt="" width="684" height="643" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png 684w, https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection-300x282.png 300w" sizes="(max-width: 684px) 100vw, 684px" /></a></li>
</ol>
<h2>Configuring the Google Drive Connector</h2>
<ol>
<li>Use a preinstalled Google Drive Connector from the Popular Connector List or press the Search Online radio button to download Google Drive Connector. Once downloaded simply use it in the configuration:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10354" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png" alt="ssis googledrive template selection walkthrough" width="781" height="686" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png 781w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough-300x264.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough-768x675.png 768w" sizes="(max-width: 781px) 100vw, 781px" /></a></li>
<li>Proceed with selecting the desired Authentication Type. Then select API Base URL (in most cases default one is the right one). Finally, fill in all the required parameters and set optional parameters if needed.</li>
<li>After configuring all the required properties in the API Connection Manager, please click on the &#8220;Test Connection&#8221; button to confirm that the connection is established successfully.<br />
<h3>Method1: Connect to Google Drive using User Account [OAuth]</h3>
<p>You may press a link <a href="https://zappysys.com/api/integration-hub/google-drive-connector/help/authentication/OAuth"><strong>Steps to Configure</strong></a> which will help set certain parameters.</p>
<div id="attachment_10355" style="width: 876px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10355" class="size-full wp-image-10355" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png" alt="SSIS API Source - Generate Token - Google Drive with User Account" width="866" height="773" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png 866w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token-300x268.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token-768x686.png 768w" sizes="(max-width: 866px) 100vw, 866px" /></a><p id="caption-attachment-10355" class="wp-caption-text">SSIS API Source &#8211; Generate Token &#8211; Google Drive with User Account</p></div>
<h3>Method2: Connect to Google Drive using Service Account [OAuth]</h3>
<p>You may press a link <a href="https://zappysys.com/api/integration-hub/google-drive-connector/help/authentication/ServiceAccount"><strong>Steps to Configure</strong></a> which will help set certain parameters.</p>
<div id="attachment_10353" style="width: 876px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10353" class="size-full wp-image-10353" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png" alt="SSIS API Source - Generate Token - Google Drive with Service Account" width="866" height="773" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png 866w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token-300x268.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token-768x686.png 768w" sizes="(max-width: 866px) 100vw, 866px" /></a><p id="caption-attachment-10353" class="wp-caption-text">SSIS API Source &#8211; Generate Token &#8211; Google Drive with Service Account</p></div></li>
</ol>
<h2>How to download a single file from Google Drive</h2>
<p>In the API Source Component, we&#8217;ve chosen the API Connection Manager. Next, we need to configure the remaining properties of the component to download the single file from Google Drive.</p>
<ol>
<li>Choose the <strong>Download a file</strong> endpoint from the &#8220;Select Table/Endpoint&#8221; dropdown menu.</li>
<li>To access detailed API documentation for downloading files, you can click on the following link: <a href="https://developers.google.com/drive/api/reference/rest/v3/files/get"><strong>Help for: Download a File</strong></a>.</li>
<li>Please choose a File ID from the drop-down menu to indicate which file you wish to download. This is an essential parameter for the download process.</li>
<li>Please indicate the desired filename for the file being downloaded by setting the <strong>FileName</strong> parameter.</li>
<li>If you intend to replace the local file with the one being downloaded, please select the &#8216;<strong>AlwaysOverwrite</strong>&#8216; option from the dropdown menu labeled &#8216;<strong>FileOverwriteMode</strong>&#8216;. Alternatively, you can choose &#8216;FileIfExists&#8217; or &#8216;SkipIfExists&#8217; based on your specific needs.</li>
</ol>
<p>Please refer to the sample screenshot below.</p>
<div id="attachment_10690" style="width: 896px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-source-googledrive-single-file-download.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10690" class="wp-image-10690 size-full" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-source-googledrive-single-file-download.png" alt="SSIS API Source - Google Drive - Download Single File" width="886" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-source-googledrive-single-file-download.png 886w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-source-googledrive-single-file-download-300x204.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-source-googledrive-single-file-download-768x523.png 768w" sizes="(max-width: 886px) 100vw, 886px" /></a><p id="caption-attachment-10690" class="wp-caption-text">SSIS API Source &#8211; Google Drive &#8211; Download Single File</p></div>
<p>Once you have configured all the mentioned properties above, please click on the &#8220;Preview Data&#8221; button to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the <strong>ZappySys Google Drive Connector</strong> for downloading a Single file from Google Drive.</p>
<h2>How to download multiple files from Google Drive</h2>
<p>In the API Destination Component, we have chosen the API Connection Manager. Now, we must proceed to configure the remaining properties of the component to facilitate the download of multiple files from Google Drive. Additionally, we should make use of an OLE DB Source and Derived Column component to map the files for the download process.</p>
<ol>
<li>Drag and drop the OLE DB Source Component from the SSIS Toolbox. Double-click on the OLE DB Source Component to initiate its configuration.
<div id="attachment_7289" style="width: 515px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7289" class="wp-image-7289 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png" alt="OLE DB Source - Drag and Drop" width="505" height="190" srcset="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png 505w, https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop-300x113.png 300w" sizes="(max-width: 505px) 100vw, 505px" /></a><p id="caption-attachment-7289" class="wp-caption-text">OLE DB Source &#8211; Drag and Drop</p></div></li>
<li>Create a new OLE DB Connection Manager and configure your SQL Server settings for the connection. Next, select the Data access mode, specify the name of the table or view, or write an SQL Command. Afterward, click on the &#8216;Preview&#8217; button to view a preview and check the &#8216;Columns&#8217; tab for the source columns.
<div id="attachment_10693" style="width: 835px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-oledb-source-read-googledrive-filesdata-sql.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10693" class="size-full wp-image-10693" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-oledb-source-read-googledrive-filesdata-sql.png" alt="SSIS OLE DB Source - Configure SQL Connection and fetch the table data" width="825" height="717" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-oledb-source-read-googledrive-filesdata-sql.png 825w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-oledb-source-read-googledrive-filesdata-sql-300x261.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-oledb-source-read-googledrive-filesdata-sql-768x667.png 768w" sizes="(max-width: 825px) 100vw, 825px" /></a><p id="caption-attachment-10693" class="wp-caption-text">SSIS OLE DB Source &#8211; Configure SQL Connection and fetch the table data</p></div></li>
<li>Next, drag and drop the Derived Column Component from the SSIS Toolbox. Double-click on the Derived Column Component to begin its configuration.
<div id="attachment_10219" style="width: 503px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/ssis-drag-and-drop-derived-column.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10219" class="size-full wp-image-10219" src="https://zappysys.com/blog/wp-content/uploads/2020/12/ssis-drag-and-drop-derived-column.png" alt="Drag and drop the Derived Column" width="493" height="345" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/ssis-drag-and-drop-derived-column.png 493w, https://zappysys.com/blog/wp-content/uploads/2020/12/ssis-drag-and-drop-derived-column-300x210.png 300w" sizes="(max-width: 493px) 100vw, 493px" /></a><p id="caption-attachment-10219" class="wp-caption-text">Drag and drop the Derived Column</p></div></li>
<li>Now, add a new Derived Column by setting the expression to concatenate FilePath and FileName. Click &#8216;OK&#8217; to save the configuration.
<div id="attachment_10695" style="width: 869px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-derived-column-add-newcolumn-set-expression.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10695" class="wp-image-10695 size-full" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-derived-column-add-newcolumn-set-expression.png" alt="SSIS Derived Column - Add New Column &amp; Set Expression" width="859" height="622" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-derived-column-add-newcolumn-set-expression.png 859w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-derived-column-add-newcolumn-set-expression-300x217.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-derived-column-add-newcolumn-set-expression-768x556.png 768w" sizes="(max-width: 859px) 100vw, 859px" /></a><p id="caption-attachment-10695" class="wp-caption-text">SSIS Derived Column &#8211; Add New Column &amp; Set Expression</p></div></li>
<li>Now, drag and drop the API Destination Component from the SSIS Toolbox. Double-click on the API Destination Component to begin its configuration.
<div id="attachment_10697" style="width: 879px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-drag-and-drop.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10697" class="wp-image-10697 size-full" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-drag-and-drop.png" alt="Drag and Drop the SSIS API Destination Component" width="869" height="548" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-drag-and-drop.png 869w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-drag-and-drop-300x189.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-drag-and-drop-768x484.png 768w" sizes="(max-width: 869px) 100vw, 869px" /></a><p id="caption-attachment-10697" class="wp-caption-text">Drag and Drop the SSIS API Destination Component</p></div></li>
<li>Double-click on the <strong>API Destination</strong> component to configure it for uploading multiple files to Google Drive.
<ol style="list-style-type: lower-alpha;">
<li>Choose the <strong>Download a file</strong> endpoint from the &#8220;Select Table/Endpoint&#8221; dropdown menu.</li>
<li>To access detailed API documentation for downloading files, you can click on the following link: <a href="https://developers.google.com/drive/api/reference/rest/v3/files/get"><strong>Help for: Download File</strong></a>.</li>
<li>Please specify the &#8216;FileOverwriteMode&#8217; option as &#8216;AlwaysOverwrite,&#8217; or you can choose &#8216;FailIfExists&#8217; or &#8216;SkipIfExists&#8217; options based on your requirements.<br />
Please refer to the sample screenshot below.</p>
<div id="attachment_10700" style="width: 816px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-settingstab-download-multiplefile.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10700" class="wp-image-10700 size-full" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-settingstab-download-multiplefile.png" alt="SSIS API Destination Component - Configure Settings Tab" width="806" height="669" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-settingstab-download-multiplefile.png 806w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-settingstab-download-multiplefile-300x249.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-settingstab-download-multiplefile-768x637.png 768w" sizes="(max-width: 806px) 100vw, 806px" /></a><p id="caption-attachment-10700" class="wp-caption-text">SSIS API Destination Component &#8211; Configure Settings Tab</p></div></li>
<li>Now, go to the Mappings tab and specify the source columns with the corresponding target properties.<br />
Note: Here We&#8217;re mapping FileID with $$Id and FileNameWithPath with $$ResponseDataFile. You can create mappings based on your Source columns<br />
Please refer to the sample screenshot below</p>
<div id="attachment_10699" style="width: 646px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-mappingstab-download-multiplefile.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10699" class="wp-image-10699 size-full" src="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-mappingstab-download-multiplefile.png" alt="SSIS API Destination Component - Configure Mappings Tab" width="636" height="442" srcset="https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-mappingstab-download-multiplefile.png 636w, https://zappysys.com/blog/wp-content/uploads/2023/10/ssis-api-destination-configure-mappingstab-download-multiplefile-300x208.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></a><p id="caption-attachment-10699" class="wp-caption-text">SSIS API Destination Component &#8211; Configure Mappings Tab</p></div></li>
</ol>
</li>
<li>Once you have configured all the mentioned properties above, please click on the &#8220;Preview Data&#8221; button from the Settings tab to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the ZappySys Google Drive Connector for downloading multiple files from Google Drive.<br />
Please refer to the sample screenshot below.</p>
<div id="attachment_10705" style="width: 1191px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10705" class="size-full wp-image-10705" src="https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success.png" alt="Download Multiple files from Google Drive" width="1181" height="381" srcset="https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success.png 1181w, https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success-300x97.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success-768x248.png 768w, https://zappysys.com/blog/wp-content/uploads/2023/11/ssis-api-destination-download-multiplefiles-success-1024x330.png 1024w" sizes="(max-width: 1181px) 100vw, 1181px" /></a><p id="caption-attachment-10705" class="wp-caption-text">Download Multiple files from Google Drive</p></div></li>
</ol>
<h2>Conclusion</h2>
<p>In this blog, we learned how to connect with Google Drive using SSIS API Connection Manager and download single or multiple files from Google Drive using a combination of SSIS components, including the <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-source/">SSIS API Source component</a>, <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-destination/">SSIS API Destination component</a>, OLE DB Source component, and Derived Column component.</p>
<p>The post <a href="https://zappysys.com/blog/download-files-google-drive-using-ssis/">How to download files from Google Drive using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to upload files on Google Drive using SSIS</title>
		<link>https://zappysys.com/blog/upload-files-google-drive-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Thu, 07 Sep 2023 12:18:50 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[SSIS API Source]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[Foreach Loop Container]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[Google Drive]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[ssis advanced file system task]]></category>
		<category><![CDATA[upload files]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=10255</guid>

					<description><![CDATA[<p>Introduction In today&#8217;s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you&#8217;re a user of SQL Server Integration Services (SSIS) and looking to integrate Google Drive into your data workflow, you&#8217;re in luck. ZappySys SSIS PowerPack offers a powerful Google Drive Connector that [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/upload-files-google-drive-using-ssis/">How to upload files on Google Drive using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><strong>Introduction</strong></h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo.png"><img loading="lazy" decoding="async" class="alignleft wp-image-11097" src="https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-300x284.png" alt="" width="106" height="100" srcset="https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-300x284.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo-768x727.png 768w, https://zappysys.com/blog/wp-content/uploads/2023/11/google_drive_logo.png 980w" sizes="(max-width: 106px) 100vw, 106px" /></a>In today&#8217;s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you&#8217;re a user of SQL Server Integration Services (SSIS) and looking to integrate Google Drive into your data workflow, you&#8217;re in luck. ZappySys SSIS PowerPack offers a powerful <a href="https://zappysys.com/api/integration-hub/google-drive-connector/">Google Drive Connector</a> that makes uploading files to Google Drive a breeze. In this guide, we&#8217;ll walk you through the process of uploading files to Google Drive using SSIS and the <a href="https://zappysys.com/api/integration-hub/google-drive-connector/ssis">ZappySys SSIS PowerPack Google Drive Connector</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>Upload files to Google Drive with SSIS:</h2>
<p>In this section, we will learn how to configure and use Google Drive Connector in the API Source to upload files on Google Drive.</p>
<ol>
<li>Begin with opening Visual Studio and Creating a New Project.</li>
<li>Select Integration Service Project and in the new project window set the appropriate name and location for the project. Click OK.</li>
<li>In the new SSIS project screen you will find the following:
<ol style="list-style-type: lower-alpha;">
<li>SSIS ToolBox on the left sidebar</li>
<li>Solution Explorer and Property Window on the right bar</li>
<li>Control flow, data flow, event Handlers, Package Explorer in tab windows</li>
<li>Connection Manager Window at the bottom</li>
</ol>
<div id="attachment_10258" style="width: 710px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/upload-files-google-drive-using-ssis/zappysys-ssis-project-with-toolbox/#main"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10258" class="wp-image-10258" src="https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-1024x653.png" alt="zappysys ssis project with toolbox" width="700" height="447" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-1024x653.png 1024w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-300x191.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox-768x490.png 768w, https://zappysys.com/blog/wp-content/uploads/2023/08/zappysys-ssis-project-with-toolbox.png 1287w" sizes="(max-width: 700px) 100vw, 700px" /></a><p id="caption-attachment-10258" class="wp-caption-text">SSIS Toolbox &#8211; ZappySys Tasks</p></div>
<div class="su-note"  style="border-color:#e5dd9d;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:#fff7b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE</strong>: If you don&#8217;t see ZappySys SSIS PowerPack Task or Components in the SSIS Toolbox, please refer to <a href="https://zappysys.zendesk.com/hc/en-us/articles/115004935754-I-don-t-see-PowerPack-components-in-SSIS-Toolbox">this help link</a>.</div></div></li>
<li>Now, Drag and Drop the SSIS Data Flow Task from the SSIS Toolbox. Double-click on the Data Flow Task to see the Data Flow Designer.<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10260" src="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png" alt="" width="460" height="155" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task.png 460w, https://zappysys.com/blog/wp-content/uploads/2023/08/drag-and-drop-data-flow-task-300x101.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></a></li>
<li>From the SSIS toolbox drag and drop API Source (Predefined Templates) on the data flow designer surface, and double-click on it to edit it:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10262" src="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg" alt="" width="659" height="292" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg 659w, https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop-300x133.jpg 300w" sizes="(max-width: 659px) 100vw, 659px" /></a></li>
<li>Select <strong>New Connection</strong> to create a new connection:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10263" src="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png" alt="" width="684" height="643" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection.png 684w, https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-new-connection-300x282.png 300w" sizes="(max-width: 684px) 100vw, 684px" /></a></li>
</ol>
<h2>Configuring the Google Drive Connector</h2>
<ol>
<li>Use a preinstalled Google Drive Connector from the Popular Connector List or press the Search Online radio button to download Google Drive Connector. Once downloaded simply use it in the configuration:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10354" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png" alt="ssis googledrive template selection walkthrough" width="781" height="686" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough.png 781w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough-300x264.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-template-selection-googledrive-walkthrough-768x675.png 768w" sizes="(max-width: 781px) 100vw, 781px" /></a></li>
<li>Proceed with selecting the desired Authentication Type. Then select API Base URL (in most cases default one is the right one). Finally, fill in all the required parameters and set optional parameters if needed.</li>
<li>After configuring all the required properties in the API Connection Manager, please click on the &#8220;Test Connection&#8221; button to confirm that the connection is established successfully.<br />
<h3>Method1: Connect to Google Drive using User Account [OAuth]</h3>
<p>You may press a link <a href="https://zappysys.com/api/integration-hub/google-drive-connector/help/authentication/OAuth"><strong>Steps to Configure</strong></a> which will help set certain parameters.</p>
<div id="attachment_10355" style="width: 876px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10355" class="size-full wp-image-10355" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png" alt="SSIS API Source - Generate Token - Google Drive with User Account" width="866" height="773" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token.png 866w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token-300x268.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-generate-token-768x686.png 768w" sizes="(max-width: 866px) 100vw, 866px" /></a><p id="caption-attachment-10355" class="wp-caption-text">SSIS API Source &#8211; Generate Token &#8211; Google Drive with User Account</p></div>
<h3>Method2: Connect to Google Drive using Service Account [OAuth]</h3>
<p>You may press a link <a href="https://zappysys.com/api/integration-hub/google-drive-connector/help/authentication/ServiceAccount"><strong>Steps to Configure</strong></a> which will help set certain parameters.</p>
<div id="attachment_10353" style="width: 876px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10353" class="size-full wp-image-10353" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png" alt="SSIS API Source - Generate Token - Google Drive with Service Account" width="866" height="773" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token.png 866w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token-300x268.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-serviceaccount-generate-token-768x686.png 768w" sizes="(max-width: 866px) 100vw, 866px" /></a><p id="caption-attachment-10353" class="wp-caption-text">SSIS API Source &#8211; Generate Token &#8211; Google Drive with Service Account</p></div></li>
</ol>
<h2>How to upload a local file to Google Drive</h2>
<p>In the API Source Component, we&#8217;ve chosen the API Connection Manager. Next, we need to configure the remaining properties of the component to upload a local file to Google Drive.</p>
<ol>
<li>Choose the <strong>Upload a file</strong> endpoint from the &#8220;Select Table/Endpoint&#8221; dropdown menu.</li>
<li>To access detailed API documentation for uploading files, you can click on the following link: <a href="https://developers.google.com/drive/api/reference/rest/v3/files/create"><strong>Help for: Upload File</strong></a>.</li>
<li>Please specify the desired filename for the uploaded file by setting the <strong>FileName</strong> parameter.</li>
<li>Specify the desired local file path by setting the <strong>DiskFilePath</strong> parameter.</li>
<li>If you wish to upload the local file to a specific folder in Google Drive, please choose the folder ID from the dropdown menu labeled <strong>ParentFolderId</strong>. Otherwise, you can skip this parameter as it&#8217;s optional.</li>
</ol>
<p>Please refer to the sample screenshot below.</p>
<div id="attachment_10357" style="width: 896px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-single-file-upload.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10357" class="size-full wp-image-10357" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-single-file-upload.png" alt="SSIS API Source - Google Drive - Upload Single File" width="886" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-single-file-upload.png 886w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-single-file-upload-300x204.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-single-file-upload-768x523.png 768w" sizes="(max-width: 886px) 100vw, 886px" /></a><p id="caption-attachment-10357" class="wp-caption-text">SSIS API Source &#8211; Google Drive &#8211; Upload Single File</p></div>
<p>Once you have configured all the mentioned properties above, please click on the &#8220;Preview Data&#8221; button to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the <strong>ZappySys Google Drive Connector</strong> for uploading a local file to Google Drive.</p>
<h2>How to upload multiple files to Google Drive</h2>
<p>In the API Source Component, we&#8217;ve selected the API Connection Manager. Next, we need to configure the remaining properties of the component to upload multiple files to Google Drive. Additionally, we should utilize a Foreach Loop Container to iterate through each file one by one in a loop.</p>
<ol>
<li>Create 3 SSIS variables as described below.<br />
<table border="1">
<tbody>
<tr>
<th>Variable Name</th>
<th>Datatype</th>
<th>Value</th>
</tr>
<tr>
<td>varFileLists</td>
<td>Object</td>
<td>System.Object</td>
</tr>
<tr>
<td>varFileName</td>
<td>String</td>
<td>fake.extension</td>
</tr>
<tr>
<td>varFullFilePath</td>
<td>String</td>
<td>C:/fake/fake.extension</td>
</tr>
</tbody>
</table>
</li>
<li>Go to Control Flow, From the SSIS toolbox drag and drop <strong>ZS Advanced File System Task</strong> on the control flow designer surface, and double click on it to edit it:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-drag-and-drop.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10363" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-drag-and-drop.png" alt="SSIS Advanced File System Task - Drag &amp; Drop" width="580" height="241" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-drag-and-drop.png 580w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-drag-and-drop-300x125.png 300w" sizes="(max-width: 580px) 100vw, 580px" /></a></li>
<li>Select the &#8220;Get file list as ADO.NET Data Table&#8221; action from the Action drop-down menu. Set the file path in the Path textbox. Choose the variable (Object type) where you want to store the file list, and then click the OK button to save the settings.
<div id="attachment_10364" style="width: 722px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-store-filelists-adotable-in-object-variable.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10364" class="size-full wp-image-10364" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-store-filelists-adotable-in-object-variable.png" alt="SSIS Advanced File System Task - Get file list as ADO.net Data Table" width="712" height="623" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-store-filelists-adotable-in-object-variable.png 712w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-advanced-file-system-task-store-filelists-adotable-in-object-variable-300x263.png 300w" sizes="(max-width: 712px) 100vw, 712px" /></a><p id="caption-attachment-10364" class="wp-caption-text">SSIS Advanced File System Task &#8211; Get file list as ADO.net Data Table</p></div></li>
<li>Now, drag and drop the &#8220;Foreach Loop Container&#8221; from the SSIS Toolbox and connect it with the &#8220;ZS Advanced File System Task.&#8221; Double-click on the &#8220;Foreach Loop Container&#8221; to edit its properties.
<div id="attachment_10365" style="width: 750px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-foreach-loop-container-drag-and-drop-googledrive.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10365" class="size-full wp-image-10365" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-foreach-loop-container-drag-and-drop-googledrive.png" alt="SSIS Foreach Loop Container - Drag &amp; Drop" width="740" height="531" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-foreach-loop-container-drag-and-drop-googledrive.png 740w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-foreach-loop-container-drag-and-drop-googledrive-300x215.png 300w" sizes="(max-width: 740px) 100vw, 740px" /></a><p id="caption-attachment-10365" class="wp-caption-text">SSIS Foreach Loop Container &#8211; Drag &amp; Drop</p></div></li>
<li>In the Foreach Loop Editor&#8217;s &#8220;Collection&#8221; tab, choose the Enumerator as &#8220;Foreach ADO Enumerator.&#8221; In the &#8220;ADO object source variable&#8221; field, select your SSIS object-typed variable. Select the &#8220;Rows in the first table&#8221; radio option.
<div id="attachment_10371" style="width: 747px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-collection-tab-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10371" class="size-full wp-image-10371" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-collection-tab-configuration.png" alt="SSIS Foreach Loop Editor - Collection - Select Variable &amp; Enumeration mode" width="737" height="631" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-collection-tab-configuration.png 737w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-collection-tab-configuration-300x257.png 300w" sizes="(max-width: 737px) 100vw, 737px" /></a><p id="caption-attachment-10371" class="wp-caption-text">SSIS Foreach Loop Editor &#8211; Collection &#8211; Select Variable &amp; Enumeration mode</p></div></li>
<li>In the Foreach Loop Editor&#8217;s &#8220;Variable Mappings&#8221; tab, select the variables that you want to map to the values from the collection, and then click the &#8220;OK&#8221; button to save your selections.
<div id="attachment_10370" style="width: 747px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-variablemappings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10370" class="size-full wp-image-10370" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-variablemappings.png" alt="SSIS Foreach Loop Editor - Variable Mappings tab" width="737" height="631" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-variablemappings.png 737w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-googledrive-multiplefiles-upload-foreach-loop-editor-variablemappings-300x257.png 300w" sizes="(max-width: 737px) 100vw, 737px" /></a><p id="caption-attachment-10370" class="wp-caption-text">SSIS Foreach Loop Editor &#8211; Variable Mappings</p></div></li>
<li>Inside the Foreach Loop Container, drag and drop the Data Flow Task, and then rename it according to your preference.
<div id="attachment_10374" style="width: 716px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-dataflow-task-inside-foreachloop-container-googledrive-multiplefiles-upload.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10374" class="size-full wp-image-10374" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-dataflow-task-inside-foreachloop-container-googledrive-multiplefiles-upload.png" alt="SSIS Data Flow Task - Drag &amp; Drop inside Foreach Loop Container" width="706" height="420" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-dataflow-task-inside-foreachloop-container-googledrive-multiplefiles-upload.png 706w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-dataflow-task-inside-foreachloop-container-googledrive-multiplefiles-upload-300x178.png 300w" sizes="(max-width: 706px) 100vw, 706px" /></a><p id="caption-attachment-10374" class="wp-caption-text">SSIS Data Flow Task &#8211; Drag &amp; Drop inside Foreach Loop Container</p></div></li>
<li>Double-click on the Data Flow Task to see the Data Flow Designer, From the SSIS toolbox drag and drop API Source (Predefined Templates) on the data flow designer surface, and double click on it to edit it:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-10262" src="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg" alt="SSIS API Source - Drag &amp; Drop" width="659" height="292" srcset="https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop.jpg 659w, https://zappysys.com/blog/wp-content/uploads/2023/08/ssis-api-source-drag-and-drop-300x133.jpg 300w" sizes="(max-width: 659px) 100vw, 659px" /></a></li>
<li>Double-click on the <strong>API Source</strong> component to configure it for uploading multiple files to Google Drive.
<ol style="list-style-type: lower-alpha;">
<li>Choose the <strong>Upload a file</strong> endpoint from the &#8220;Select Table/Endpoint&#8221; dropdown menu.</li>
<li>To access detailed API documentation for uploading files, you can click on the following link: <a href="https://developers.google.com/drive/api/reference/rest/v3/files/create"><strong>Help for: Upload File</strong></a>.</li>
<li>Please specify the desired SSIS Variable [varFileName] which contains file name for the uploaded file by setting the <strong>FileName</strong> parameter.</li>
<li>To specify the desired local SSIS variable [varFullFilePath], which holds the file path, set the <strong>DiskFilePath</strong> parameter.<br />
When configuring the SSIS variable directly in the Raw Edit, JSON may become invalid due to the requirement of slashes within the local file path. To address this, we use a JSONENC Placeholder Function for proper escaping.<br />
<pre class="crayon-plain-tag">&lt;&lt;{{User::varUserFullFilePath}},FUN_JSONENC&gt;&gt;</pre></li>
<li>If you wish to upload the local file to a specific folder in Google Drive, please choose the folder ID from the dropdown menu labeled <strong>ParentFolderId</strong>. Otherwise, you can skip this parameter as it&#8217;s optional.</li>
</ol>
<p>Please refer to the sample screenshot below.</p>
<div id="attachment_10369" style="width: 896px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-multiple-files-upload.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10369" class="size-full wp-image-10369" src="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-multiple-files-upload.png" alt="SSIS API Source - Google Drive - Upload Multiple files - configuration" width="886" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-multiple-files-upload.png 886w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-multiple-files-upload-300x204.png 300w, https://zappysys.com/blog/wp-content/uploads/2023/09/ssis-api-source-googledrive-multiple-files-upload-768x523.png 768w" sizes="(max-width: 886px) 100vw, 886px" /></a><p id="caption-attachment-10369" class="wp-caption-text">SSIS API Source &#8211; Google Drive &#8211; Upload Multiple files configuration</p></div>
<p>To configure dynamic filenames and file paths, you can set variables. Click on &#8220;Raw Edit,&#8221; and in the &#8220;Edit Parameters&#8221; popup, you can use SSIS variables, as shown in the image below.</p>
<p>Once you have configured all the mentioned properties above, please click on the &#8220;Preview Data&#8221; button to initiate the API call. With just a few clicks, we have successfully configured the call to Google Drive using the <strong>ZappySys Google Drive Connector</strong> for uploading multiple files to Google Drive.</li>
</ol>
<h2>Conclusion</h2>
<p>In this blog, we learned how to connect with Google Drive using SSIS API Connection Manager and upload single or multiple files to Google Drive using a combination of SSIS components, including the <a href="https://zappysys.com/products/ssis-powerpack/ssis-api-source/">SSIS API Source component</a>, <a href="https://zappysys.com/products/ssis-powerpack/ssis-file-system-task-advanced/">SSIS ZS Advanced File System Task</a>, Foreach Loop Container, and SSIS variables.</p>
<p>The post <a href="https://zappysys.com/blog/upload-files-google-drive-using-ssis/">How to upload files on Google Drive using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to write/update Google Sheet in SSIS</title>
		<link>https://zappysys.com/blog/write-update-google-sheet-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Wed, 11 Dec 2019 12:29:14 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Connection]]></category>
		<category><![CDATA[Destination]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[oledb]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[put]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[sheet]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[spreadsheet]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[write]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=8475</guid>

					<description><![CDATA[<p>Introduction In this post, you will learn How to write/update Google Sheet in SSIS. We will use drag and drop REST API connectors from SSIS PowerPack. No need to download any SDK or learn programming languages (e.g. JAVA, C#, Ruby, Python) when you use SSIS PowerPack Connectors. We will use the Google Drive API and Google Sheet API [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/write-update-google-sheet-ssis/">How to write/update Google Sheet in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><span id="Introduction">Introduction</span></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/google-sheets-connector/">API Connector for Google Sheets Online</a> which makes it much simpler to <strong>Read/Write  Google Sheets 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/2016/09/google-sheets-api-integration.png"><img loading="lazy" decoding="async" class="size-thumbnail wp-image-1670 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2016/09/google-sheets-api-integration-150x150.png" alt="" width="150" height="150" /></a>In this post, you will learn How to write/update Google Sheet in SSIS. We will use drag and drop REST API connectors from <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a>. No need to download any SDK or learn programming languages (e.g. JAVA, C#, Ruby, Python) when you use SSIS PowerPack Connectors. We will use the Google Drive API and Google Sheet API to write and update Google Spreadsheet in a few clicks (using OAuth 2.0 connection in SSIS).</p>
<p>In this tutorial, we will use the <a href="https://zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to call some API. We will use the <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth connection</a> along the <a href="https://zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to write / update data to Google Spreadsheet.</p>
<p>&nbsp;</p>
<h2><span id="Prerequisites">Prerequisites</span></h2>
<p>Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:</p>
<ol>
<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 Microsoft site</a>).</li>
<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
<li>Make sure <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a> is installed (<a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">download it</a>).</li>
<li>Credentials of Google API.</li>
</ol>
<h2>Component Mention in this article</h2>
<div class="su-table su-table-alternate">
<table style="height: 44px;width: 307px">
<tbody>
<tr style="height: 22px">
<td style="height: 22px;width: 1px"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-generator-transform/ssis-json-generator-transform.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-3074" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-generator-transform/ssis-json-generator-transform.png" alt="" width="40" height="40" /></a></td>
<td style="height: 22px;width: 247px"><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">JSON Generator Transform</a></td>
</tr>
<tr style="height: 22px">
<td style="height: 22px;width: 1px"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/web-api-destination/ssis-web-api-destination.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-3074" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/web-api-destination/ssis-web-api-destination.png" alt="" width="40" height="40" /></a></td>
<td style="height: 22px;width: 247px"><a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a></td>
</tr>
<tr style="height: 22px">
<td style="height: 22px;width: 1px"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/rest-api-task/ssis-rest-api-web-service-task.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-3074" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/rest-api-task/ssis-rest-api-web-service-task.png" alt="" width="40" height="40" /></a></td>
<td style="height: 22px;width: 247px"><a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a></td>
</tr>
</tbody>
</table>
</div>
<h2><span id="Create_Google_API_Project">Create a Google API Project</span></h2>
<p>The first step to access any Google API is to create an API Project in Google Console. If you don’t want to go through this then Skip this Step-1 and in the next section select the Default OAuth App option on OAth Connection Manager (This is the easiest option for now unless you want to use your own OAuth App).</p>
<p><a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Check this article</a> for step-by-step instructions. When you follow these instructions make sure you <a href="https://console.developers.google.com/apis/api/sheets.googleapis.com/overview?project=603281348663" target="_blank" rel="noopener">enable Google Sheet API.</a></p>
<h2><span id="Create_OAuth_Connection_Manager_in_SSIS">Create OAuth Connection Manager in SSIS</span></h2>
<p>Once you create a Google API project and obtained a Client ID and Client Secret your next step is to create <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> in SSIS. ZappySys OAuth connection manager comes with many predefined OAuth Providers (e.g. Facebook, Twitter, Google, etc) but you can also define custom OAuth settings for any OAuth enabled API.</p>
<p>To create SSIS OAuth 2.0 Connection for Google API perform the following steps.</p>
<ol>
<li>Download and Install SSIS PowerPack.</li>
<li>Create a new SSIS Package.</li>
<li>Right-click in Connection Manager Area and Click “New Connection”.</li>
<li>When prompted select ZS-OAUTH connection type, On the OAuth Connection Manager Select Provider=Google.</li>
<li>Click here to <a href="https://console.developers.google.com/apis/credentials" target="_blank" rel="noopener">create credentials.</a> Then select the “Use Custom OAuth App” option and enter your ClientID, ClientSecret.</li>
<li>In the Scopes <strong>enter below scopes</strong> (or click Select Scopes). This will allow read/write access to Drive Files or Sheet (E.g. Reading file content / Export file to CSV). You can use the Scope browser to see many other available permissions. For more information click <a href="https://developers.google.com/sheets/api/guides/authorizing#OAuth2Authorizing" target="_blank" rel="noopener">here.</a><br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/spreadsheets.readonly</pre>
</li>
<li>Click on the Generate Token button.
<div id="attachment_8479" style="width: 1036px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8479" class="wp-image-8479 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file.png" alt="SSIS OAuth Connection Manager – Access Google Drive API using OAuth 2.0" width="1026" height="653" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file.png 1026w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file-300x191.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file-768x489.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-google-oauth-connection-google-drive-api-access-file-1024x652.png 1024w" sizes="(max-width: 1026px) 100vw, 1026px" /></a><p id="caption-attachment-8479" class="wp-caption-text">SSIS OAuth Connection Manager – Access Google Drive API using OAuth 2.0</p></div></li>
<li>You will see UI as below… Click Allow (You may have to scroll to see that button sometimes).</li>
<li>Click on Test Connection to see the connection is working and click on the OK button to save configure setting UI.</li>
</ol>
<h2><span id="Find_Google_Sheet_ID_for_API_call">Find Google Sheet ID for API calls</span></h2>
<p>Before we can write or update Sheet data in SSIS we need to know Google Driver File ID. We will use this ID in the next few sections.</p>
<p>The easiest way to find File ID is to look at the URL like below. If you need to know ID at runtime dynamically then refer to the last section.</p>
<div id="attachment_8450" style="width: 806px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8450" class="wp-image-8450 size-full" src="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png" alt="Get Google Drive File ID for API call (Sheet ID)" width="796" height="286" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png 796w, https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call-300x108.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call-768x276.png 768w" sizes="(max-width: 796px) 100vw, 796px" /></a><p id="caption-attachment-8450" class="wp-caption-text">Get Google Drive File ID for API call (Sheet ID)</p></div>
<h2>Create Variables to make dynamic URL</h2>
<ol>
<li>Here, we are going to make a Dynamic URL value.</li>
<li>In Visual Studio Project Right Click on Design Panel, Select Variables.
<div style="width: 426px" class="wp-caption aligncenter"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/ssis-create-variable.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/ssis-create-variable.png" alt="Create Variables" width="416" height="294" /></a><p class="wp-caption-text">Create Variables</p></div></li>
<li>Let&#8217;s Create Variables with correct DataType and Value. In variable &#8220;<strong>varRange</strong>&#8221; set only the starting point(<strong>Sheet1!A2</strong>) of data if you don&#8217;t know the ending point and leave the first-row for giving header row later or click <a href="https://zappysys.com/blog/write-update-google-sheet-ssis/#Update_Google_Sheet_header_cells_manually" target="_blank" rel="noopener">here.</a><br />
<a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-create-variable.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="aligncenter wp-image-8547 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-create-variable.png" alt="Create Variables with correct datatype and values" width="863" height="209" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-create-variable.png 863w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-create-variable-300x73.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-create-variable-768x186.png 768w" sizes="(max-width: 863px) 100vw, 863px" /></a></li>
</ol>
<h2>Write SQL Server data to Google Spreadsheet</h2>
<p>Now let’s look at a real-world example. How to write data from SQL Server table or other source and send to Google Sheet using Web API Destination.</p>
<ol>
<li>Drag and Drop SSIS Data Flow Task from SSIS Toolbox.
<div id="attachment_8028" style="width: 470px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8028" class="wp-image-8028 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task.png" alt="Dragging and dropping Data Flow Task into Control Flow" width="460" height="155" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task.png 460w, https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task-300x101.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></a><p id="caption-attachment-8028" class="wp-caption-text">Dragging and dropping Data Flow Task into Control Flow</p></div></li>
<li>Double click on the Data Flow task to see the Data Flow designer surface.</li>
<li>Here, In Visual Studio, drag and drop the OLE DB Source, JSON Generator Transform and Web API Destination in the design surface and join the components with the blue arrow.
<div id="attachment_8491" style="width: 611px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-drag-drop-json-generator-web-api-destination.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8491" class="wp-image-8491 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-drag-drop-json-generator-web-api-destination.png" alt="Drag and Drop OLE DB Source, JSON Generator Transform and Web API Destination" width="601" height="369" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-drag-drop-json-generator-web-api-destination.png 601w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-drag-drop-json-generator-web-api-destination-300x184.png 300w" sizes="(max-width: 601px) 100vw, 601px" /></a><p id="caption-attachment-8491" class="wp-caption-text">Drag and Drop OLE DB Source, JSON Generator Transform, and Web API Destination</p></div></li>
<li>Here, you can use our Free ZS Dummy Data Source too. Click <a href="https://zappysys.com/products/ssis-powerpack/dummy-data-source-free/" target="_blank" rel="noopener">here</a> for more information.</li>
<li>But, we are going through OLE DB Source so we need OLEDB Connection.</li>
</ol>
<h3>Create OLE DB Connection</h3>
<ol>
<li>Lets, create the OLE DB Connection.</li>
<li>Let&#8217;s, Right-click on Connection Managers Panel to Create OLEDB Connection, so you can use Source and Context Menu will appear, Select New OLEDB Connection from the Context Menu.
<div style="width: 485px" class="wp-caption aligncenter"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-1.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-1.png" alt="Create OLE DB Connection" width="475" height="353" /></a><p class="wp-caption-text">Create OLE DB Connection</p></div></li>
<li>Now, click on New Button to create Connection.
<div style="width: 665px" class="wp-caption aligncenter"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-2.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-2.png" alt="Create New Connection" width="655" height="558" /></a><p class="wp-caption-text">Create New Connection</p></div></li>
<li>Let&#8217;s Configure Connection Manager, just Follow steps one by one as we have created.
<div style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-3.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/oledb-connection-manager/ssis-new-oledb-connection-step-3.png" alt="Configure OLE DB Connection" width="720" height="625" /></a><p class="wp-caption-text">Configure OLE DB Connection</p></div></li>
<li>Click on Test Connection to see correct configure it.</li>
<li>Click on the OK button to save connection configure setting UI.</li>
</ol>
<h3>Configure JSON Generator Transform</h3>
<ol>
<li>Double click on JSON Generator Transform to configure it.</li>
<li>Set Output Mode to <strong>Single Dataset Array</strong>. Right-click on Mappings, select Add Static Element then enter Name: &#8220;<strong>range</strong>&#8221; and Select variable we have created for value.
<div id="attachment_8492" style="width: 929px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8492" class="wp-image-8492 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value.png" alt="Configure JSON Generator Transform - Add Static Value" width="919" height="730" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value.png 919w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-300x238.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-768x610.png 768w" sizes="(max-width: 919px) 100vw, 919px" /></a><p id="caption-attachment-8492" class="wp-caption-text">Configure JSON Generator Transform &#8211; Add Static Value</p></div></li>
<li>Again, Right-click on Mappings, select Add Static Element then enter Name: &#8220;<strong>majorDimension</strong>&#8221; and Value: &#8220;<strong>ROWS</strong>&#8220;.
<div id="attachment_8493" style="width: 946px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-2.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8493" class="wp-image-8493 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-2.png" alt="Configure JSON Generator Transform - Add Static Value" width="936" height="730" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-2.png 936w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-2-300x234.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-static-value-2-768x599.png 768w" sizes="(max-width: 936px) 100vw, 936px" /></a><p id="caption-attachment-8493" class="wp-caption-text">Configure JSON Generator Transform &#8211; Add Static Value</p></div></li>
<li>Now, Right-click on Mappings, select Add Document Array, Check to Treat as <strong>2D array</strong> option and enter Element Name as &#8220;<strong>values</strong>&#8220;.
<div id="attachment_8494" style="width: 1047px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8494" class="wp-image-8494 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array.png" alt="Configure JSON Generator Transform - Add Document Array" width="1037" height="764" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array.png 1037w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array-300x221.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array-768x566.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-document-array-1024x754.png 1024w" sizes="(max-width: 1037px) 100vw, 1037px" /></a><p id="caption-attachment-8494" class="wp-caption-text">Configure JSON Generator Transform &#8211; Add Document Array</p></div></li>
<li>Then, right-click on Document Array, select <strong>Add elements</strong> &gt; Select <strong>Add Multiple Columns</strong> and check on columns you like to add.
<div id="attachment_8495" style="width: 1047px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8495" class="wp-image-8495 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement.png" alt="Configure JSON Generator Transform - Add Element" width="1037" height="764" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement.png 1037w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement-300x221.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement-768x566.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-json-generator-addelement-1024x754.png 1024w" sizes="(max-width: 1037px) 100vw, 1037px" /></a><p id="caption-attachment-8495" class="wp-caption-text">Configure JSON Generator Transform &#8211; Add Element</p></div></li>
<li>Click on the OK button to save JSON Generator Transform configure setting UI.</li>
</ol>
<h3>Configure Web API Destination</h3>
<ol>
<li>Double click on Web API Destination to configure it.</li>
<li>Select the OAuth connection manager created in an earlier section (Assuming you had all scopes with write permission).</li>
<li>In the Setting tab,
<ol>
<li>In URL, Generate Dynamic URL like below. Change Sheet ID, Range designator(including Sheet name) and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}/values/{{User::varRange}}:{{User::varSpreadsheetValues}}?valueInputOption={{User::varValueInputOption}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A2:B4:append?valueInputOption=USER_ENTERED</pre>
</li>
<li>Change Request Method to <strong>POST.</strong></li>
<li>Select JSON Generator variable into <strong>Body (Request Data)</strong> or you can select <strong>Input column</strong> for <strong>Body </strong>(JSON Generator Output).</li>
<li>Set <strong><strong><strong>application/JSON </strong></strong></strong>to Body Content-type.
<div id="attachment_8497" style="width: 1214px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8497" class="wp-image-8497 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination.png" alt="Configure Web API Destination" width="1204" height="725" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination.png 1204w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination-300x181.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination-768x462.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-configure-web-api-destination-1024x617.png 1024w" sizes="(max-width: 1204px) 100vw, 1204px" /></a><p id="caption-attachment-8497" class="wp-caption-text">Configure Web API Destination</p></div></li>
</ol>
</li>
<li>Click on the OK button to save Web API Destination configure setting UI.</li>
<li>That&#8217;s all, You are ready to Run or Execute Task and verify data into Google spreadsheet. Now update header row values for click <a href="https://zappysys.com/blog/write-update-google-sheet-ssis/#Update_Google_Sheet_header_cells_manually">here.</a>
<div id="attachment_8530" style="width: 1147px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8530" class="wp-image-8530 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1.png" alt="Run or Execute Package and verify data into Google Spreadsheet" width="1137" height="556" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1.png 1137w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1-300x147.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1-768x376.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-execute-1-1024x501.png 1024w" sizes="(max-width: 1137px) 100vw, 1137px" /></a><p id="caption-attachment-8530" class="wp-caption-text">Run or Execute Package and verify data into Google Spreadsheet</p></div></li>
</ol>
<h2><span id="Write_data_to_Google_Spread_Sheet">Append data to Google SpreadSheet using REST API Task</span></h2>
<p>Now let&#8217;s look at how to write to Google SpreadSheet. To write multiple rows in a single request. Also, check this link to <a href="https://developers.google.com/sheets/api/guides/values" target="_blank" rel="noopener">learn more</a>.</p>
<p>For more information, you can see the <a href="https://developers.google.com/sheets/api/samples/writing" target="_blank" rel="noopener">example here</a>. For parameter, detail review this API documentation.</p>
<p>You can use<a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener"> SSIS REST API Task</a> or <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> to achieve the Spreadsheet write scenario. For a simple example, let&#8217;s use the REST API Task.</p>
<ol>
<li>Drag and Drop ZS REST API Task on the control flow designer.
<div id="attachment_3777" style="width: 577px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-rest-api-task-share-post-on-linkedin.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3777" class="wp-image-3777 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-rest-api-task-share-post-on-linkedin.png" alt="Drag and Drop REST API Task" width="567" height="297" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-rest-api-task-share-post-on-linkedin.png 567w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-rest-api-task-share-post-on-linkedin-300x157.png 300w" sizes="(max-width: 567px) 100vw, 567px" /></a><p id="caption-attachment-3777" class="wp-caption-text">Drag and Drop REST API Task</p></div></li>
<li>Double click on ZS REST API Task to configure it.</li>
<li>In the Request Settings tab,
<ol>
<li>set Request URL Access Mode to Url from a connection. Select OAuth Connection from the dropdown (Same connection we created in the previous section).</li>
<li>Enter the URL below. Change Sheet ID, Range designator(including Sheet name) and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}/values/{{User::varRange}}:{{User::varSpreadsheetValues}}?valueInputOption={{User::varValueInputOption}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A1:append?valueInputOption=USER_ENTERED</pre>
</li>
<li>Change Request Method to <strong>POST.</strong></li>
<li>Enter Request Body as below<br />
<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>Note:</strong> For example purpose, we included header line in data cells but in the real-world header may already exist in the sheet.</div></div>
<pre class="crayon-plain-tag">{
  "range": "{{User::varRange}}",
  "majorDimension": "ROWS",
  "values": [
    ["Item", "Cost", "Stocked", "Ship Date"],
    ["Wheel", "$20.50", "4", "3/1/2016"],
    ["Door", "$15", "2", "3/15/2016"],
    ["Engine", "$100", "1", "3/20/2016"],
    ["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"]
  ]
}</pre>
</li>
<li>Change Request Content type to <strong><strong><strong>application/JSON.</strong></strong></strong>
<div id="attachment_8482" style="width: 1335px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8482" class="wp-image-8482 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth.png" alt="Write data to Google SpreadSheet using REST API Task (OAuth 2.0 Connection)" width="1325" height="762" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth.png 1325w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth-300x173.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth-768x442.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-post-google-spreadsheet-using-rest-api-oauth-1024x589.png 1024w" sizes="(max-width: 1325px) 100vw, 1325px" /></a><p id="caption-attachment-8482" class="wp-caption-text">Write data to Google SpreadSheet using REST API Task (OAuth 2.0 Connection)</p></div></li>
</ol>
</li>
<li>Click on the OK button to save REST API Task configure setting UI.</li>
<li>That&#8217;s all, You are ready to Run or Execute Task and verify data into Google spreadsheet.
<div id="attachment_8481" style="width: 1390px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8481" class="wp-image-8481 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute.png" alt="Execute REST API Task and verify Google Spreadsheet data " width="1380" height="671" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute.png 1380w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute-300x146.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute-768x373.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-google-spreadsheet-using-rest-api-oauth-post-execute-1024x498.png 1024w" sizes="(max-width: 1380px) 100vw, 1380px" /></a><p id="caption-attachment-8481" class="wp-caption-text">Execute REST API Task and verify Google Spreadsheet data</p></div></li>
</ol>
<h2><span id="Update_Google_Sheet_Cells_8211_Single_Range_Set_Values_for_multiple_cells">Update Google Sheet Cells</span></h2>
<p>Now let’s look at the below example of updating multiple cells in google Spreadsheet. For more information, you can see the <a href="https://developers.google.com/sheets/api/samples/writing" target="_blank" rel="noopener">example here</a>. For parameter, detail review this API documentation.</p>
<p>You can use<a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener"> SSIS REST API Task</a> or <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> to achieve the Spreadsheet Update scenario. For a simple example, let&#8217;s use the REST API Task.</p>
<h3>Update Google Sheet header cells manually</h3>
<ol>
<li>Drag and drop ZS REST API Tasks on the control flow designer.</li>
<li>Double click on the First REST API Task to configure it.</li>
<li>In the Request Settings tab,
<ol>
<li>Enter the URL below. Change Range designator(including Sheet name: <strong>Sheet1!A1</strong>) and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}/values/{{User::varRange}}?valueInputOption={{User::varValueInputOption}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A1?valueInputOption=USER_ENTERED</pre>
</li>
<li>Change Request Method to <strong>PUT.</strong></li>
<li>Enter Request Body as below<br />
<pre class="crayon-plain-tag">{
  "range": "{{User::varRange}}",
  "majorDimension": "ROWS",
  "values": [
    ["CustomerID", "CustomerName"]
  ]
}</pre>
</li>
</ol>
</li>
<li>Click on the OK button to save REST API Task configure setting UI.</li>
<li>That&#8217;s all, You are ready to Run or Execute Task and verify data into Google spreadsheet.<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-8532" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth.png" alt="" width="1318" height="677" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth.png 1318w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth-300x154.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth-768x394.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-update-put-google-spreadsheet-using-rest-api-oauth-1024x526.png 1024w" sizes="(max-width: 1318px) 100vw, 1318px" /></a></li>
</ol>
<h3><span id="Update_Google_Sheet_Cells_8211_Single_Range_Set_Values_for_multiple_cells">Single Range (Set Values for multiple cells)</span></h3>
<ol>
<li>Follow the previous section(write data to Google Spreadsheet) to update sheet data.</li>
<li>In the Request Settings tab,
<ol>
<li>Enter the URL below. Change Sheet ID, Range designator(including Sheet name) and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}/values/{{User::varRange}}?valueInputOption={{User::varValueInputOption}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A2:B4?valueInputOption=USER_ENTERED</pre>
</li>
<li>Change Request Method to <strong>PUT.</strong></li>
<li>Enter Request Body as below<br />
<pre class="crayon-plain-tag">{
  "range": "{{User::varRange}}",
  "majorDimension": "ROWS",
  "values": [
    ["Laptop", "$2000.50"],
    ["Mobile", "$1150"]
  ]
}</pre>
</li>
</ol>
</li>
<li>That&#8217;s all, click on the Test Request/Response button and verify data into Google spreadsheet.
<div id="attachment_8485" style="width: 1610px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8485" class="wp-image-8485 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth.png" alt="Calling Google Sheet API to Update Multiple Cell Values" width="1600" height="860" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth.png 1600w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth-300x161.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth-768x413.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-write-put-google-spreadsheet-using-rest-api-oauth-1024x550.png 1024w" sizes="(max-width: 1600px) 100vw, 1600px" /></a><p id="caption-attachment-8485" class="wp-caption-text">Calling Google Sheet API to Update Multiple Cell Values</p></div></li>
</ol>
<h2><span id="Write_data_to_Google_Spread_Sheet">Clear data to Google SpreadSheet using REST API Task</span></h2>
<h3 id="clear_a_sheet_of_all_values_while_preserving_formats">Clear a sheet of all values while preserving formats</h3>
<p>Lets clear a sheet of all values by REST API Task, Before processed we need sheet Id. So let&#8217;s get the SheetId by API Call. For more information about click <a href="https://developers.google.com/sheets/api/samples/sheet#clear_a_sheet_of_all_values_while_preserving_formats" target="_blank" rel="noopener">here.</a></p>
<ol>
<li>Drag and Drop two ZS REST API Tasks on the control flow designer and rename(Get Sheet ID and Clear Google Sheet of all values) it.</li>
<li>Double click on the First REST API(Get Sheet ID) Task to configure it.</li>
<li>In the Request Settings tab,
<ol>
<li>Enter the URL below. Change Sheet ID and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc</pre>
</li>
<li>Change Request Method to <strong><strong>GET.<br />
</strong></strong><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-getsheetid.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="wp-image-8515 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-getsheetid.png" alt="REST API Task - Get Google Sheet ID" width="923" height="661" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-getsheetid.png 923w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-getsheetid-300x215.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-getsheetid-768x550.png 768w" sizes="(max-width: 923px) 100vw, 923px" /></a>REST API Task &#8211; Get Google Sheet ID</li>
</ol>
</li>
<li>Now go to Response Settings Tab, Select Response content Type Json and Write Response Content Filter Expression. Check on Save Response Content. Select Save Mode to Variable and Create a New variable or select it.<br />
<strong>Example of Response Content Filter Expression for the first Sheet : </strong><br />
<pre class="crayon-plain-tag">$.sheets.[0].properties.sheetId</pre>
<div id="attachment_8517" style="width: 757px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-savesheetid.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8517" class="wp-image-8517 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-savesheetid.png" alt="REST API Task - Save Google Sheet ID into Variable" width="747" height="613" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-savesheetid.png 747w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-savesheetid-300x246.png 300w" sizes="(max-width: 747px) 100vw, 747px" /></a><p id="caption-attachment-8517" class="wp-caption-text">REST API Task &#8211; Save Google Sheet ID into Variable</p></div></li>
<li>Now, click on the Test Request/Response to check configures are ok.</li>
<li>Click on the OK button to save REST API Task configure setting UI.</li>
<li>Double click on the second REST API(Clear Google Sheet of all values) Task to configure it.</li>
<li>In the Request Settings tab,
<ol>
<li>Enter the URL below. Change Sheet ID and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}:batchUpdate</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc:batchUpdate</pre>
</li>
<li>Change Request Method to <strong>POST. </strong>Enter Request Body as below and change a variable parameter as per your need.<br />
<pre class="crayon-plain-tag">{
  "requests": [
    {
      "updateCells": {
        "range": {
          "sheetId": {{User::varGoogleSheetID}}
        },
        "fields": "userEnteredValue"
      }
    }
  ]
}</pre>
</li>
<li>Change Request Content type to <strong>application/JSON.<br />
</strong></p>
<div id="attachment_8518" style="width: 1109px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8518" class="wp-image-8518 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth.png" alt="REST API Task Configure - Clear sheet of all values" width="1099" height="763" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth.png 1099w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-300x208.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-768x533.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-clear-google-spreadsheet-using-rest-api-oauth-1024x711.png 1024w" sizes="(max-width: 1099px) 100vw, 1099px" /></a><p id="caption-attachment-8518" class="wp-caption-text">REST API Task Configure &#8211; Clear sheet of all values</p></div></li>
</ol>
</li>
<li>Click on the OK button to save REST API Task configure setting UI.</li>
<li>That&#8217;s all, You are ready to Run or Execute Task and verify data into Google spreadsheet.</li>
</ol>
<h3>Clears range cell values from a spreadsheet</h3>
<ol>
<li>Double click on REST API Task to configure it. Then, follow the way just like the previous section configures REST API Task.</li>
<li>Here you need to set the value of Variable &#8220;<strong>varSpreadsheetValues</strong>&#8221; to &#8220;<strong>clear</strong>&#8221; or you can change it directly in URL <strong>append to clear </strong>and value of variable &#8220;<strong>varRange</strong>&#8221; (Change cell range and sheet name) as per your need. For more information about it click <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear" target="_blank" rel="noopener">here.</a>
<ol>
<li>Enter the URL below. Change Sheet ID, Range designator(including Sheet name) and API URL Parameters as per your need.<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{{User::varGoogleSpreadsheetID}}/values/{{User::varRange}}:{{User::varSpreadsheetValues}}?valueInputOption={{User::varValueInputOption}}</pre>
<strong>Example URL without variables (some part masked with xxxxxxxx):</strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A2:B4:clear?valueInputOption=USER_ENTERED</pre>
</li>
</ol>
</li>
<li>Change Request Method to <strong>POST.</strong></li>
<li>Enter Request Body as below<br />
<pre class="crayon-plain-tag">{}</pre>
</li>
<li>Change Request Content type to <strong><strong><strong>application/JSON.</strong></strong></strong></li>
<li>That&#8217;s all, click on the Test Request/Response button and verify data into Google spreadsheet.</li>
</ol>
<h2><span id="Conclusion">Conclusion</span></h2>
<p>Google Drive API and Google Sheets API provide a great way to automate file-related functionality. However, to call Google API  you have to use the SDK / coding approach (e.g. C#, Java, Python, Ruby). Luckily ZappySys <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> provides a great way to integrate any Google API call via simple drag and drop approach without coding. Try out yourself see how long it takes to call virtually any REST API.</p>
<h2>References</h2>
<p>Finally, you can use the following links for more information:</p>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">JSON Generator 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-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a></li>
<li>Help File:
<ul>
<li><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-json-generator-transform.htm" target="_blank" rel="noopener">JSON Generator Transform</a></li>
<li><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-web-api-destination.htm" target="_blank" rel="noopener">Web API Destination</a></li>
<li><a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-rest-api-web-service-task.htm" target="_blank" rel="noopener">REST API Task</a></li>
</ul>
</li>
</ul>
<p>The post <a href="https://zappysys.com/blog/write-update-google-sheet-ssis/">How to write/update Google Sheet in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Import Google Analytics data into SQL Server / Reporting / ETL</title>
		<link>https://zappysys.com/blog/import-google-analytics-data-sql-server-reporting-etl/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 25 May 2019 19:17:14 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[ODBC Gateway]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[T-SQL (SQL Server)]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[openquery]]></category>
		<category><![CDATA[power bi]]></category>
		<category><![CDATA[ssms]]></category>
		<category><![CDATA[ssrs]]></category>
		<category><![CDATA[t-sql]]></category>
		<category><![CDATA[tableau]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=7003</guid>

					<description><![CDATA[<p>Introduction In our previous article we saw how to read Google Analytics data using SSIS. But what if you don&#8217;t use SSIS and you still like to Import Google Analytics data into SQL Server or Read inside other Reporting / ETL Apps (e.g. Excel, Power BI, MS Access &#8230; and many more). Not all BI [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/import-google-analytics-data-sql-server-reporting-etl/">Import Google Analytics data into SQL Server / Reporting / ETL</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/2019/05/google-analytics-logo.png"><img loading="lazy" decoding="async" class=" wp-image-7056 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2019/05/google-analytics-logo.png" alt="" width="162" height="162" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/google-analytics-logo.png 250w, https://zappysys.com/blog/wp-content/uploads/2019/05/google-analytics-logo-150x150.png 150w" sizes="(max-width: 162px) 100vw, 162px" /></a>In our previous article we saw how to <a href="https://zappysys.com/blog/get-data-from-google-analytics-in-ssis-using-rest-api-call/">read Google Analytics data using SSIS</a>. But what if you don&#8217;t use SSIS and you still like to Import Google Analytics data into SQL Server or Read inside other Reporting / ETL Apps (e.g. Excel, Power BI, MS Access &#8230; and many more). Not all BI tools comes with native driver / connectivity for Google Analytics. Sometimes they do offer Google Analytics connectivity but don&#8217;t offer feature you looking for (e.g. Sort, Segment Filter). In such case you have to look for solution outside.</p>
<p>Well not to worry we will show you how simple it is to connect to Google Analytics using <a href="https://zappysys.com/products/odbc-powerpack/odbc-json-rest-api-driver/" target="_blank" rel="noopener">ZappySys JSON Driver (For REST API / Files)</a> in few mins. This driver is one of the best REST API drivers you can find in the market. It is so generic that it can virtually access any REST API you may find internally or on public sites (e.g. Facebook, Salesforce, Azure, AWS). Check <a href="https://zappysys.com/blog/category/odbc-powerpack/odbc-drivers/json-rest-api-driver/" target="_blank" rel="noopener">these articles</a> to see many more use cases of JSON Driver.</p>
<p>At the end of this article you will learn how to Query Google Analytics data in <strong>SSMS</strong> like below (Yes that&#8217;s correct .. Pretty Awesome!!! ).</p>
<div id="attachment_7046" style="width: 649px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7046" class="size-full wp-image-7046" src="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png" alt="Import Google Analytics Data into SQL Server Table (using T-SQL Code)" width="639" height="538" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png 639w, https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server-300x253.png 300w" sizes="(max-width: 639px) 100vw, 639px" /></a><p id="caption-attachment-7046" class="wp-caption-text">Import Google Analytics Data into SQL Server Table (using T-SQL Code)</p></div>
<div class="content_block" id="custom_post_widget-7048"><h2>Requirements</h2>
This article talks about few tools and techniques in order to load API data in SQL Server. Please make sure following prerequisites are met.
<ol>
 	<li>Download and Install <a href="https://zappysys.com/products/odbc-powerpack/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a> (This includes XML / JSON / REST API and few other drivers for SQL Server and ODBC connectivity in tools like Excel, Power BI, SSRS)</li>
 	<li>Make sure you have access to SQL Server Instance. If you cant find one still want to try what is mentioned in this article then install <a href="https://www.microsoft.com/en-us/sql-server/sql-server-editions-express" target="_blank" rel="noopener">FREE SQL Express Edition</a></li>
 	<li>Confirm that you have SSMS Installed. If you don't have then you can download <a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-2017">from here</a>.</li>
</ol></div>
<h2>Testing Google Analytics API</h2>
<p>If you are new to Google Analytics API then read little bit about <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference#data_request" target="_blank" rel="noopener">Google Analytics REST API here</a>. Google also offers a really good way to test Analytics API using <a href="https://ga-dev-tools.appspot.com/query-explorer/" target="_blank" rel="noopener">Query Explorer Tool here</a>. So please check that and understand how to craft correct REST API URL which will be used in the next section.</p>
<div id="attachment_7021" style="width: 908px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7021" class="size-full wp-image-7021" src="https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer.png" alt="Using Google Analytics Query Explorer Tool - Create REST API Url (Dimension / Metrics Selection Browser)" width="898" height="1379" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer.png 898w, https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer-195x300.png 195w, https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer-768x1179.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/generate-google-analytics-rest-api-url-query-explorer-667x1024.png 667w" sizes="(max-width: 898px) 100vw, 898px" /></a><p id="caption-attachment-7021" class="wp-caption-text">Using Google Analytics Query Explorer Tool &#8211; Create REST API Url (Dimension / Metrics Selection Browser)</p></div>
<h3>Sample Google Analytics API Response</h3>
<p>Behind the scene here is how API Request and Response Looks like for Google Analytics REST API. Notice that <strong>Authorization</strong> Header in below request is automatically added by ZappySys Driver or Query Testing tool above. Also notice <strong>nextLink</strong> attribute in response, its used to fetch more data. By default each response contains upto 10000 rows.</p>
<p><strong>Request</strong></p><pre class="crayon-plain-tag">GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga:185737326&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:avgSessionDuration&amp;dimensions=ga:date
Authorization: Bearer ya29.GlwUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</pre><p>
<strong>Response</strong></p><pre class="crayon-plain-tag">{
    "kind": "analytics#gaData",
    "id": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:123456789&amp;dimensions=ga:date&amp;metrics=ga:avgSessionDuration&amp;start-date=30daysAgo&amp;end-date=yesterday",
    "query": {
        "start-date": "30daysAgo",
        "end-date": "yesterday",
        "ids": "ga:123456789",
        "dimensions": "ga:date",
        "metrics": ["ga:avgSessionDuration"],
        "start-index": 1,
        "max-results": 1000
    },
    "itemsPerPage": 1000,
    "totalResults": 30,
    "selfLink": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:123456789&amp;dimensions=ga:date&amp;metrics=ga:avgSessionDuration&amp;start-date=30daysAgo&amp;end-date=yesterday",
    "nextLink": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:123456789&amp;dimensions=ga:date&amp;metrics=ga:avgSessionDuration&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;start-index=10001&amp;max-results=10000",
    "profileInfo": {
        "profileId": "123456789",
        "accountId": "33445566",
        "webPropertyId": "UA-33445566-3",
        "internalWebPropertyId": "454545454",
        "profileName": "All Web Site Data",
        "tableId": "ga:123456789"
    },
    "containsSampledData": false,
    "columnHeaders": [
        {
            "name": "ga:date",
            "columnType": "DIMENSION",
            "dataType": "STRING"
        },
        {
            "name": "ga:avgSessionDuration",
            "columnType": "METRIC",
            "dataType": "TIME"
        }
    ], "totalsForAllResults": {
        "ga:avgSessionDuration": "49.3779488037477"
    },
    "rows": [ 
		["20190425", "401.38912133891213"], 
		["20190426", "512.49723756906077"], 
		["20190427", "11.53488372093024"], 
		["20190428", "432.148648648648646"], 
		["20190429", "234.650735294117645"],
		.......
		.......
		.......
		.......
		["20190525", "74.123435294117645"]
	]
}</pre><p>
&nbsp;</p>
<h2>Creating Google API Project (Obtain Client ID / Secret)</h2>
<p>Very first step to call any Google API including Google Analytics is to create Google API Project and register OAuth App to obtain <strong>Client ID</strong> and <strong>Client Secret</strong>. If you dont want to go through this hassle and start easy way then ZappySys offers Inbuilt Default App on <strong>OAuth</strong> Connection UI but <strong>we strongly recommend</strong> you create your own app rather than using Default App because in Default App API call limit is shared by many. Your data is never shared with ZappySys in any case even you use Default App.</p>
<p>Here is how to <a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/">create API Project to call Google API</a>. Once you create Google API Project make sure you <strong>enable</strong> <strong>Google Analytics API</strong>.</p>
<p>So once you have <strong>Client ID</strong> and <strong>Client Secret</strong> we can move forward to the next step.</p>
<h2>Loading Google Analytics data into SQL Server</h2>
<p>In our previous article we saw in depth general idea on how to <a href="https://zappysys.com/blog/import-rest-api-json-sql-server/">import REST API data in SQL Server (T-SQL Script)</a> without relying on any ETL tools.  Now lets look at step by step on <strong>how to load Google Analytics data into SQL Server</strong>.</p>
<p>In this example, our goal is to extract a Google Analytics report which shows average session duration and new users count by date (For last 30 days).</p>
<h3>Setup ZappySys Data Gateway</h3>
<p>Very first step to access any REST API Data inside SQL Server is to configure ZappySys Data Gateway. We covered this in <a href="https://zappysys.com/blog/import-rest-api-json-sql-server/" target="_blank" rel="noopener">previous article</a>.  But here are high level steps for initial setup of Data Gateway.</p>
<ol>
<li>Search for Gateway in Start menu and  Select ZappySys Data Gateway
<div id="attachment_5283" style="width: 410px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/start-menu-open-zappysys-data-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5283" class="size-full wp-image-5283" src="https://zappysys.com/blog/wp-content/uploads/2018/11/start-menu-open-zappysys-data-gateway.png" alt="Open ZappySys Data Gateway" width="400" height="315" srcset="https://zappysys.com/blog/wp-content/uploads/2018/11/start-menu-open-zappysys-data-gateway.png 400w, https://zappysys.com/blog/wp-content/uploads/2018/11/start-menu-open-zappysys-data-gateway-300x236.png 300w" sizes="(max-width: 400px) 100vw, 400px" /></a><p id="caption-attachment-5283" class="wp-caption-text">Open ZappySys Data Gateway</p></div></li>
<li>Create <strong>new User</strong> in Data gateway on Users tab. Enter username and password (we will use this when we create Linked Server) . <strong><strong><strong>Check Admin Option</strong></strong></strong>
<div id="attachment_5285" style="width: 426px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-user.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5285" class="size-full wp-image-5285" src="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-user.png" alt="Add Data Gateway User" width="416" height="444" srcset="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-user.png 416w, https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-user-281x300.png 281w" sizes="(max-width: 416px) 100vw, 416px" /></a><p id="caption-attachment-5285" class="wp-caption-text">Add Data Gateway User</p></div></li>
</ol>
<h3>Setup Google Analytics API Data Source in Gateway / ODBC</h3>
<p>Once gateway user is setup, now lets create a new Data Source for Google Analytics API. In this section we will talk how to create data source in gateway but most instructions can be used to create data source in ODBC too. At the end of this article we explained how to Launch ODBC Datasource UI. Step#1 and 2 are only different, all other steps same in ODBC DSN creation.</p>
<ol>
<li>Click Add Data Source option (Select Native &#8211; JSON Driver )
<div id="attachment_5284" style="width: 568px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5284" class="size-full wp-image-5284" src="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source.png" alt="Add Gateway Data Source (Native JSON Driver)" width="558" height="533" srcset="https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source.png 558w, https://zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source-300x287.png 300w" sizes="(max-width: 558px) 100vw, 558px" /></a><p id="caption-attachment-5284" class="wp-caption-text">Add Gateway Data Source (Native JSON Driver)</p></div></li>
<li>Click Edit to configure data source
<div id="attachment_5440" style="width: 572px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/gateway-create-datasource-2-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-5440" class="size-full wp-image-5440" src="https://zappysys.com/blog/wp-content/uploads/2018/11/gateway-create-datasource-2-2.png" alt="Edit Gateway Data Source Settings" width="562" height="385" srcset="https://zappysys.com/blog/wp-content/uploads/2018/11/gateway-create-datasource-2-2.png 562w, https://zappysys.com/blog/wp-content/uploads/2018/11/gateway-create-datasource-2-2-300x206.png 300w" sizes="(max-width: 562px) 100vw, 562px" /></a><p id="caption-attachment-5440" class="wp-caption-text">Edit Gateway Data Source Settings</p></div></li>
<li>Now lets configure Driver settings.  Click on Load Connection String button.
<div id="attachment_7024" style="width: 996px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/zappysys-driver-load-connectionstring.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7024" class="size-full wp-image-7024" src="https://zappysys.com/blog/wp-content/uploads/2019/05/zappysys-driver-load-connectionstring.png" alt="Load ZappySys Driver ConnectionString to configure UI" width="986" height="454" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/zappysys-driver-load-connectionstring.png 986w, https://zappysys.com/blog/wp-content/uploads/2019/05/zappysys-driver-load-connectionstring-300x138.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/zappysys-driver-load-connectionstring-768x354.png 768w" sizes="(max-width: 986px) 100vw, 986px" /></a><p id="caption-attachment-7024" class="wp-caption-text">Load ZappySys Driver ConnectionString to configure UI</p></div></li>
<li>Enter the following ConnectionString to get started with predefined settings.<br />
Change ids (<strong>111223344</strong> to your own Profile ID in <strong>DataPath URL</strong>). Other URL Parameters explained in next section.<br />
<pre class="crayon-plain-tag">DRIVER={ZappySys JSON Driver};
DataPath='https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:avgSessionDuration,ga:newUsers&amp;dimensions=ga:date';
DataConnectionType=OAuth;
ScopeSeparator='{space}';
Scope='https://www.googleapis.com/auth/analytics https://www.googleapis.com/auth/analytics.readonly';
ServiceProvider=Google;
Filter='$.rows[*]';
ArrayTransformType=TransformSimpleTwoDimensionalArray;
ArrayTransColumnNameFilter='$.columnHeaders[*].name';
RequestMethod='GET';
NextUrlAttributeOrExpr='$.nextLink';
ClientId='xxxxxxxxxxxx';
ClientSecret='yyyyyyyyyyyyyy';
UseCustomApp='True'</pre>
&nbsp;</li>
<li>URL used in DataPath is most important (parameters explained below) . You can use   <a href="https://ga-dev-tools.appspot.com/query-explorer/" target="_blank" rel="noopener">Query Explorer Tool here</a> to build same URL.<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:avgSessionDuration,ga:newUsers&amp;dimensions=ga:date</pre>
<strong><span style="text-decoration: underline;">Parameters Explained </span><br />
</strong><br />
Here is some required parameters used in above REST API URL.<br />
<strong>ids</strong>=ga:11223344<br />
This is your Profile ID which you like to extract.  <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference#ids">Read more</a><strong><br />
start-date</strong>=30daysAgo<br />
This can be yyyy-MM-dd or some other some predefined date keywords (e.g today, yesterday 10daysAgo). <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference#startDate" target="_blank" rel="noopener">Read more</a>.<br />
<strong>end-date</strong>=yesterday<br />
Same as above<br />
<strong>metrics</strong>=ga:avgSessionDuration,ga:newUsers<br />
This can be comma separated list of metrics you like to extract (max 10). <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference#metrics" target="_blank" rel="noopener">Read more</a>.<br />
<strong>dimensions</strong>=ga:date<br />
This can be comma separated list of metrics you like to extract (max 7). <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference#dimensions" target="_blank" rel="noopener">Read more</a>.</li>
<li>Now its time to configure <a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">OAuth</a> settings. Click on Configure Connection. Enter Client ID and Client Secret Obtained in the previous section (<a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">see here</a>) and then click Generate Token as below.
<div id="attachment_7043" style="width: 1006px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/configure-google-analytics-api-driver-data-source-oauth.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7043" class="size-full wp-image-7043" src="https://zappysys.com/blog/wp-content/uploads/2019/05/configure-google-analytics-api-driver-data-source-oauth.png" alt="Configure Google API Data Source / DSN (Google Analytics API Example)" width="996" height="870" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/configure-google-analytics-api-driver-data-source-oauth.png 996w, https://zappysys.com/blog/wp-content/uploads/2019/05/configure-google-analytics-api-driver-data-source-oauth-300x262.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/configure-google-analytics-api-driver-data-source-oauth-768x671.png 768w" sizes="(max-width: 996px) 100vw, 996px" /></a><p id="caption-attachment-7043" class="wp-caption-text">Configure Google API Data Source / DSN (Google Analytics API Example)</p></div></li>
<li>Thats it now can click on Preview Tab and run sample query like below.<br />
<pre class="crayon-plain-tag">select * from $</pre>
<strong>&#8211;OR&#8211;</strong><br />
(Select Table name from dropdown and generate default query and then you can add alias , remove unwanted columns)<br />
<pre class="crayon-plain-tag">SELECT 
"ga:date" date, 
"ga:avgSessionDuration" avgSessionDuration,
"ga:newUsers" newUsers
FROM "rows"</pre>
<strong>&#8211;OR&#8211;</strong><br />
(Type custom query with your own URL generated <a href="https://ga-dev-tools.appspot.com/query-explorer/" target="_blank" rel="noopener">from here</a>, Change Profile ID &#8211; from 11223344 to your own id)<br />
<pre class="crayon-plain-tag">SELECT * FROM $
WITH(
	 Src='https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:avgSessionDuration,ga:newUsers&amp;dimensions=ga:date'
	,IncludeParentColumns='False'
)</pre>
<a href="https://zappysys.com/blog/wp-content/uploads/2019/05/query-google-analytics-data.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-7045" src="https://zappysys.com/blog/wp-content/uploads/2019/05/query-google-analytics-data.png" alt="" width="652" height="608" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/query-google-analytics-data.png 652w, https://zappysys.com/blog/wp-content/uploads/2019/05/query-google-analytics-data-300x280.png 300w" sizes="(max-width: 652px) 100vw, 652px" /></a></li>
</ol>
<h3>Create Linked Server in SQL Server using T-SQL Script</h3>
<p>Once our Gateway Data Source is configured we can now move to SQL Server Part to define Linked Server.</p>
<p>Here is how you can define linked server to access Google Analytics Data inside SQL Server. There are two ways to create Linked Server (1)  via T-SQL script (2) via SSMS UI)</p>
<p>Here is how to create using Script.</p><pre class="crayon-plain-tag">USE [master]
GO

--drop existing linked server for same name if already found
EXEC master.dbo.sp_dropserver @server=N'GOOGLE_ANALYTICS_LS', @droplogins='droplogins'
GO

EXEC master.dbo.sp_addlinkedserver 
	@server = N'GOOGLE_ANALYTICS_LS', 
	@srvproduct=N'', 
	@provider=N'SQLNCLI', 
	@datasrc=N'localhost,5000', --this is host name and port number where  ZappySys Data Gateway is running
	@catalog=N'ZS-GA' --this must be same name as defined on Data Source tab Grid on ZappySys Data Gateway

EXEC master.dbo.sp_addlinkedsrvlogin 
	@rmtsrvname=N'GOOGLE_ANALYTICS_LS',
	@useself=N'False',
	@locallogin=NULL,
	@rmtuser=N'SOME-GATEWAY-USER', -- user name created on ZappySys Data Gateway
	@rmtpassword='SOME-GATEWAY-PASSWORD' -- password for ZappySys Data Gateway user
GO</pre><p>
&nbsp;</p>
<h3>Create Microsoft SQL Server Linked Server using SSMS UI</h3>
<div class="content_block" id="custom_post_widget-5289">Once you configured data source in Gateway, we can now setup Linked Server in SQL Server to query API data.
<ol style="margin-left: 10px;">
 	<li>Assuming you have installed SQL Server and SSMS. If not then get both for FREE from here: <a href="https://www.microsoft.com/en-us/sql-server/sql-server-editions-express">Get SQL Server Express</a> and  <a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms" target="_blank" rel="noopener">Get SSMS</a></li>
 	<li>Open SSMS and connect to SQL Server.</li>
 	<li>Go to Root &gt; Server Objects &gt; Linked Servers node. Right click and click <strong>New Linked Server...
</strong>
<div class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/create-new-linked-server-ssms.png">
<img decoding="async" src="https://zappysys.com/blog/wp-content/uploads/2018/03/create-new-linked-server-ssms.png" alt="Add Linked Server in SQL Server" />
</a>
<p class="wp-caption-text">Add Linked Server in SQL Server</p>

</div></li>
 	<li> Now enter linked server name, select Provider as SQL Native Client</li>
 	<li>Enter data source as <strong><span class="lang:default decode:true crayon-inline">GatewayServerName,PORT_NUMBER</span></strong> where server name is where ZappySys Gateway is running (Can be same as SQL Server machine or remote machine). Default PORT_NUMBER is 5000 but confirm on Data gateway &gt; General tab incase its different.</li>
 	<li>Enter Catalog Name. This must match name from Data gateway Data sources grid &gt; Name column
<div class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/ssms-sql-server-configure-linked-server-2.png">
<img decoding="async" src="https://zappysys.com/blog/wp-content/uploads/2018/11/ssms-sql-server-configure-linked-server-2.png" alt="Configure Linked Server Provider, Catalog, Server, Port for ZappySys Data Gateway Connection" />
</a>
<p class="wp-caption-text">Configure Linked Server Provider, Catalog, Server, Port for ZappySys Data Gateway Connection</p>
</div>
<div style="color: #31708f;background-color: #d9edf7;border-color: #bce8f1;padding: 15px;margin-bottom: 20px;border: 1px solid transparent;border-radius: 4px;">
<strong>INFO:</strong><br/>
<ul>
    <li>
      For <strong>SQL Server 2012, 2014, 2016, 2017, and 2019</strong>, use the <em>SQL Server Native Client 11.0</em> as the Provider.
    </li>
    <li>
      For <strong>SQL Server 2022 or higher</strong>, use the <em>Microsoft OLE DB Driver for SQL Server</em> as the Provider.
    </li>
  </ul>
</div></li>
 	<li>Click on Security Tab and select last option "<strong>Be made using this security context</strong>". Enter your gateway user account here.</li>
<li>
        <p>Optional: Under the Server Options Tab, Enable <b>RPC</b> and <b>RPC Out</b> and Disable Promotion of Distributed Transactions<b>(MSDTC)</b>.</p>
		<div class="wp-caption alignnone">
			<img decoding="async" class="block margin-bottom-10 img-thumbnail" src="https://zappysys.com/blog/wp-content/uploads/2018/11/linked-server-options-rpc-msdtc.png" title="RPC and MSDTC Settings" alt="RPC and MSDTC Settings" />
			<p class="wp-caption-text">RPC and MSDTC Settings</p>
		</div>
        <hr />
        <p>
            You need to enable RPC Out if you plan to use <b><i>EXEC(...) AT [MY_LINKED_SERVER_NAME]</i></b> rather than OPENQUERY.
            <br />
            If don't enabled it, you will encounter the <i>'Server "MY_LINKED_SERVER_NAME" is not configured for RPC'</i> error.
        </p>
        <p>
            Query Example:
            <code class="sql">EXEC('Select * from Products') AT [MY_LINKED_SERVER_NAME]</code>
        </p>
        <hr />
        <p>
            If you plan to use <b><i>'INSERT INTO...EXEC(....) AT [MY_LINKED_SERVER_NAME]'</i></b> in that case you need to Disable Promotion of Distributed Transactions(MSDTC).
            <br />
            If don't disabled it, you will encounter the <i>'The operation could not be performed because OLE DB provider "SQLNCLI11/MSOLEDBSQL" for linked server "MY_LINKED_SERVER_NAME" was unable to begin a distributed transaction.'</i> error.
        </p>
        <p>
            Query Example:
<pre class="">Insert Into dbo.Products 
EXEC('Select * from Products') AT [MY_LINKED_SERVER_NAME]</pre>
        </p>
        <hr />
</li>
 	<li>Click OK to save Linked Server</li>
 	<li>In SSMS execute below SQL query to test your connectivity.
<pre class="">SELECT * FROM OPENQUERY( MY_LINKED_SERVER_NAME, 'SELECT * FROM $')</pre>
--OR--
<pre class="">SELECT * FROM OPENQUERY( MY_LINKED_SERVER_NAME, 
'SELECT * FROM $
 WITH (Src=''https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json''
 ,Filter=''$.value[*]''
 ,DataFormat=''OData''
)');</pre>
</li>
 	<li>Here is the preview after you run some REST API query in SQL Server. Notice that you can override default configuration by supplying <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/json-odbc-driver-connectionstring.htm" target="_blank" rel="noopener">many parameters</a> in WITH clause (second query example in screenshot).
<div class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/11/query-rest-api-sql-server-linked-server-openquery-zappysys-data-gateway.png">
<img decoding="async" src="https://zappysys.com/blog/wp-content/uploads/2018/11/query-rest-api-sql-server-linked-server-openquery-zappysys-data-gateway.png" alt="SSMS Output - Query REST API via Linked Server OPENQUERY statement (Connect to ZappySys Data Gateway)" />
</a>
<p class="wp-caption-text">SSMS Output - Query REST API via Linked Server OPENQUERY statement (Connect to ZappySys Data Gateway)</p>

</div></li>
 	<li>You can wrap your queries inside View or wrap inside Stored procedure to parameterize. Here is an example of create view which calls REST API queries. Below View can be consumed like a normal table from any Tools or Programming Language which supports connectivity to SQL Server.
<pre class="lang:tsql decode:true ">CREATE VIEW dbo.vwApiInvoices 
AS 
/*Call REST API inside SQL Server View*/
SELECT * FROM OPENQUERY( LS , 
'SELECT * FROM $
WITH (Src=''https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json''
	 ,Filter=''$.value[*]''
	 ,DataFormat=''OData''
)');

GO
</pre>
&nbsp;</li>
 	<li>Notice in above approach if you parameterize Stored Procedure then <a href="https://zappysys.com/blog/create-csv-list-sql-server-table-columns-datatypes/" target="_blank" rel="noopener">check this article to understand Dynamic Metadata</a>.</li>
 	<li>That's it. We are now ready to move forward with more interesting things in next section.</li>
</ol></div>
<h3>Import Google Analytics Data into SQL Server Table (T-SQL Code)</h3>
<p>Now lets see how to run sample query to import Google Analytics Data into SQL Server. Notice that how we have escaped quotes in <strong>OPENQUERY</strong>.<br />
<strong>NOTE:</strong> Change id 11223344 with your own Id (<a href="https://ga-dev-tools.appspot.com/query-explorer/" target="_blank" rel="noopener">use this tool</a> to create URL)</p><pre class="crayon-plain-tag">select * into GaApiLoad from OPENQUERY([GOOGLE_ANALYTICS_LS] ,
'SELECT * FROM "rows"
WITH 
 (
   SRC=''https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:avgSessionDuration,ga:newUsers&amp;dimensions=ga:date''
  ,IncludeParentColumns=''False''
 )
')
select * from GaApiLoad</pre><p>
<div id="attachment_7046" style="width: 649px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7046" class="size-full wp-image-7046" src="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png" alt="Import Google Analytics Data into SQL Server Table (using T-SQL Code)" width="639" height="538" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server.png 639w, https://zappysys.com/blog/wp-content/uploads/2019/05/import-google-analytics-data-into-sql-server-300x253.png 300w" sizes="(max-width: 639px) 100vw, 639px" /></a><p id="caption-attachment-7046" class="wp-caption-text">Import Google Analytics Data into SQL Server Table (using T-SQL Code)</p></div>
<h2>Expose Google Analytics Data as View</h2>
<p>To make it simple you can expose above query as SQL Server views so you can access them from any Reporting / ETL Tools.</p><pre class="crayon-plain-tag">CREATE VIEW vw_Google_Analytics_BounceRate_PageViews_Last30Days
AS
--change ids to your own Profile ID
select * from OPENQUERY([GOOGLE_ANALYTICS_LS] ,
'SELECT * FROM "rows"
WITH 
 (
   SRC=''https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=2019-04-01&amp;end-date=2019-04-30&amp;metrics=ga:bounceRate,ga:uniquePageviews&amp;dimensions=ga:date''
  ,IncludeParentColumns=''False''
 )
')
GO</pre><p>
<h2>Making things Dynamic using Stored Procedure with Parameters</h2>
<p>Now let&#8217;s make few things dynamic. We will change above query so we can pass Id, Dimensions and Metrics as parameters.</p>
<p>Run below script to Create a stored proc and fetch google analytics data in SQL Server.</p><pre class="crayon-plain-tag">use MyDatabase
go
create proc usp_GoogleAnalyticsData
	@ids varchar(1000),
	@startDate varchar(50)='30daysAgo',
	@endDate varchar(50)='yesterday',
	@metrics varchar(200)='ga:avgSessionDuration,ga:newUsers',
	@dimensions varchar(200)='ga:date'	
as

declare @sql varchar(4000)

set @sql='select * from OPENQUERY([GOOGLE_ANALYTICS_LS] ,
''SELECT * FROM "rows"
WITH 
 (
   SRC=''''https://www.googleapis.com/analytics/v3/data/ga?ids=ga:' + @ids 
   +'&amp;start-date='+ @startDate 
   +'&amp;end-date='+ @endDate 
   +'&amp;metrics='+ @metrics 
   +'&amp;dimensions='+ @dimensions 
   +'''''
  ,IncludeParentColumns=''''False''''
 )
'')'

print @sql
execute(@sql)

go

--Example: query google analytics data
exec usp_GoogleAnalyticsData 
	@ids='11223344',  --Change this ID - Obtain from here https://ga-dev-tools.appspot.com/query-explorer/
	@startDate ='30daysAgo',  --or like this 2019-04-01
	@endDate   ='yesterday', --or like this 2019-04-30
	@dimensions='ga:date', 
	@metrics   ='ga:bounceRate,ga:uniquePageviews'</pre><p>
<h3>Insert Google Analytics Data into table (Save Stored Procedure Output)</h3>
<p>Now what if you like to save Stored Proc output into a table? Well for that you must create table with same structure as stored proc output and then use <strong>INSERT INTO</strong> sql like below.</p><pre class="crayon-plain-tag">--import google analytics data in a table
if(object_id('GaDataLoad') is not null)
	drop table GaDataLoad
create table GaDataLoad([Date] date, BounceRate numeric(10,5), PageViews numeric(10,5))  

insert into GaDataLoad
exec usp_GoogleAnalyticsData 
	@ids='11223344',  --Change this ID - Obtain from here https://ga-dev-tools.appspot.com/query-explorer/
	@startDate ='30daysAgo',  --or like this 2019-04-01
	@endDate   ='yesterday', --or like this 2019-04-30
	@dimensions='ga:date', 
	@metrics='ga:bounceRate,ga:uniquePageviews'

select * from GaDataLoad</pre><p>
&nbsp;</p>
<h2>Performance Tips / Handling data errors due to missing rows</h2>
<p>By default ZappySys API Drivers sends minimum 2 API requests. First one to fetch metadata and second, third&#8230; for Data. There will be a time when you wont have any data and it may throw error about no records found because it fails to parse metadata. You can avoid such issue by supplying metadata before hand so you can avoid expensive API calls. <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/" target="_blank" rel="noopener">Check this article</a> see how you can supply cached metadata in your SQL Query as below. This will avoid Metadata call and speedup significantly. It will also avoid errors due to no rows found for specified criteria.</p><pre class="crayon-plain-tag">select * from OPENQUERY([GOOGLE_ANALYTICS_LS] ,
'SELECT * FROM "rows"
WITH 
 (
   SRC=''https://www.googleapis.com/analytics/v3/data/ga?ids=ga:11223344&amp;start-date=30daysAgo&amp;end-date=yesterday&amp;metrics=ga:bounceRate,ga:uniquePageviews&amp;dimensions=ga:date''
  ,IncludeParentColumns=''False''
  ,Meta=''[ 
     {"Name": "ga:date","Type": "String", "Length": 16 },
     {"Name": "ga:bounceRate", "Type": "String", "Length": 36 },
     {"Name": "ga:uniquePageviews", "Type": "String", "Length": 10 }
    ]''
 )
')</pre><p>
&nbsp;</p>
<h2>ODBC Connection &#8211; Google Analytics Data in Other Apps (e.g. SSRS / Power BI / Excel / Tableau)</h2>
<p>So far we have talked accessing data inside SQL Server using Data Gateway Approach but what if you like to access in other apps ? Well you have three options.</p>
<ol>
<li>Use Microsoft SQL Server Driver to call Linked Server Queries (OPENQUERY approach we saw earlier)</li>
<li>Access Google Analytics Data using ODBC connectivity</li>
<li>Use Microsoft SQL Server Driver to send direct SQL queries to Gateway (Bypass Linked Server &#8211; Use inner SQL query without OPENQUERY in this case)</li>
</ol>
<h3><strong>Method-1 : Linked Server Approach</strong></h3>
<p>First approach most likely works in all cases because most apps will support connecting to SQL Server using OLEDB / ADO.net / ODBC / JDBC Drivers. So calling SQL Queries which uses Linked Server (i.e. OPENQUERY statement)  is advisable.</p>
<h3><strong>Method-2 : ODBC Driver Approach</strong></h3>
<p>However in some cases this may not be possible (e.g. You don&#8217;t have SQL Server inhouse or you don&#8217;t want to rely on SQL Server to access API). In such case you can use ODBC connectivity in your app. Since ODBC is widely adopted standard most app out there (Except JAVA apps) should support ODBC Drivers. If you like to use this approach then create ODBC DSN rather than Data Gateway Data source and use it in your Reporting / ETL / Custom Apps.</p>
<p>&nbsp;</p>
<div id="attachment_6213" style="width: 404px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/01/how-to-open-odbc-data-source-administrator-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6213" class="wp-image-6213 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/01/how-to-open-odbc-data-source-administrator-2.png" alt="Open ODBC Data Sources (Create DSN)" width="394" height="542" srcset="https://zappysys.com/blog/wp-content/uploads/2019/01/how-to-open-odbc-data-source-administrator-2.png 394w, https://zappysys.com/blog/wp-content/uploads/2019/01/how-to-open-odbc-data-source-administrator-2-218x300.png 218w" sizes="(max-width: 394px) 100vw, 394px" /></a><p id="caption-attachment-6213" class="wp-caption-text">Open ODBC Data Sources (Create DSN)</p></div>
<div id="attachment_3993" style="width: 1067px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3993" class="size-full wp-image-3993" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver.png" alt="ODBC User DSN Tab: Add new Driver Screen" width="1057" height="422" srcset="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver.png 1057w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver-300x120.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver-768x307.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-user-dsn-select-driver-1024x409.png 1024w" sizes="(max-width: 1057px) 100vw, 1057px" /></a><p id="caption-attachment-3993" class="wp-caption-text">ODBC User DSN Tab: Add new Driver Screen</p></div>
<p>&nbsp;</p>
<h3><strong>Method-3 : Direct connection to Data Gateway (By pass Linked Server)</strong></h3>
<p>Last option we suggest for cases like JAVA Apps / Linux / Mac machines where you cannot install ZappySys ODBC Drivers and you dont have option to use SQL Server Linked Server either. In such case you can try to send SQL Queries to Gateway directly using Microsoft SQL Server Compatible Drivers (i.e. ODBC /JDBC). <a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/" target="_blank" rel="noopener">See this example</a> how we called API Queries inside JAVA Apps.</p>
<h3>Google Analytics / REST API Integration in various apps</h3>
<div class="content_block" id="custom_post_widget-7051">ZappySys ODBC Drivers built using ODBC standard which is widely adopted by industry for a long time. Which mean the majority of BI Tools / Database Engines / ETL Tools already there will support native / 3rd party ODBC Drivers. Below is the small list of most popular tools / programming languages our Drivers support. If your tool / programming language doesn't appear in the below list, which means we have not documented use case but as long as your tool supports ODBC Standard, our drivers should work fine.

&nbsp;

<img loading="lazy" decoding="async" class="" src="//zappysys.com/images/odbc-powerpack/odbc-powerpack-integration.jpg" alt="ZappySys ODBC Drivers for REST API, JSON, XML - Integrate with Power BI, Tableau, QlikView, QlikSense, Informatica PowerCenter, Excel, SQL Server, SSIS, SSAS, SSRS, Visual Studio / WinForm / WCF, Python, C#, VB.net, PHP. PowerShell " width="750" height="372" />
<table style="valign: top;">
<tbody>
<tr>
<td>
<p style="text-align: center;"><strong>BI / Reporting Tools
Integration</strong></p>
</td>
<td style="text-align: center;"><strong>ETL Tools
Integration
</strong></td>
<td style="text-align: center;"><strong>Programming Languages</strong>
<strong>Integration</strong></td>
</tr>
<tr>
<td>
<ul>
 	<li><a href="https://zappysys.com/blog/howto-import-json-rest-api-power-bi/" target="_blank" rel="noopener">Microsoft Power BI</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-tableau-read-json-soap-xml-csv/">Tableau</a></li>
 	<li><a href="https://zappysys.com/blog/read-rest-api-using-ssrs-reports-call-json-xml-web-service/" target="_blank" rel="noopener">SSRS (SQL Reporting Services)</a></li>
 	<li><a href="https://zappysys.com/blog/qlik-rest-connector-examples-read-json-xml-api/" target="_blank" rel="noopener">QlikView /Qlik Sense</a></li>
 	<li><a href="https://zappysys.com/blog/call-rest-api-in-microstrategy-json-soap-xml/" target="_blank" rel="noopener">MicroStrategy</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-google-sheet-call-appscript-load-json-soap-xml-csv/" target="_blank" rel="noopener">Google Sheet</a></li>
 	<li><a href="https://zappysys.com/blog/import-json-excel-load-file-rest-api/" target="_blank" rel="noopener">Microsoft Excel</a></li>
 	<li><a href="https://zappysys.com/api/integration-hub/rest-api-connector/access?context=connector" target="_blank" rel="noopener">Microsoft Access</a></li>
 	<li>Oracle OBIEE</li>
 	<li>Many more (not in this list).....</li>
</ul>
</td>
<td>
<ul>
 	<li><a href="https://zappysys.com/blog/read-json-informatica-import-rest-api-json-file/" target="_blank" rel="noopener">Informatica PowerCenter</a> (Windows)</li>
 	<li>Informatica Cloud</li>
 	<li>SSIS (SQL Integration Services)</li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-json-sql-server/" target="_blank" rel="noopener">SQL Server</a></li>
 	<li><a href="https://zappysys.com/blog/read-write-rest-api-data-in-talend-json-xml-soap/" target="_blank" rel="noopener">Talend Data Studio</a></li>
 	<li><a href="https://zappysys.com/blog/pentaho-read-rest-api-in-pentaho/" target="_blank" rel="noopener">Pentaho Kettle</a></li>
 	<li>Oracle OBIEE</li>
 	<li>Many more (not in this list).....</li>
</ul>
</td>
<td>
<ul>
 	<li>Visual Studio</li>
 	<li><a href="https://zappysys.com/blog/calling-rest-api-in-c/" target="_blank" rel="noopener">C#</a></li>
 	<li>C++</li>
 	<li><a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/" target="_blank" rel="noopener">JAVA</a></li>
 	<li><a href="https://zappysys.com/blog/set-rest-python-client/" target="_blank" rel="noopener">Python</a></li>
 	<li>PHP</li>
 	<li><a href="https://zappysys.com/blog/call-rest-api-powershell-script-export-json-csv/" target="_blank" rel="noopener">PowerShell</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-json-sql-server/" target="_blank" rel="noopener">T-SQL (Using Linked Server)</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
&nbsp;</div>
<p>&nbsp;</p>
<h2>Conclusion</h2>
<p>In this article we explored many ideas of JSON / API integration in SQL Server.  We saw how to create OAuth App for Google API and import Google Analytics data into SQL Server Table without doing any ETL using pure T-SQL code (Query / Views /Stored Procs). You can <a href="https://zappysys.com/products/odbc-powerpack/" target="_blank" rel="noopener">Download  FREE Trial of ODBC PowerPack</a> and try yourself see how easy it is to query any API inside SQL Server and avoid expensive ETL processes.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/import-google-analytics-data-sql-server-reporting-etl/">Import Google Analytics data into SQL Server / Reporting / ETL</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<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 loading="lazy" 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 loading="lazy" 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>SSIS Geocoding with Google Maps API</title>
		<link>https://zappysys.com/blog/ssis-geocoding-with-google-maps-api/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Fri, 14 Sep 2018 14:02:23 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS Components]]></category>
		<category><![CDATA[SSIS JSON Parser Transform]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[SSIS WEB API Destination]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[geocoding api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google maps api]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[reverse geocoding]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4821</guid>

					<description><![CDATA[<p>Introduction In this tutorial, we will cover the topics of how to perform geocoding on the addresses and reverse geocoding on the location coordinates using SSIS and Google Maps API. So what is geocoding, exactly? Geocoding is the process of translating an address (e.g. a street address) or a place to coordinates on the Earth&#8217;s surface. Simply [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/ssis-geocoding-with-google-maps-api/">SSIS Geocoding with Google Maps API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><img loading="lazy" decoding="async" class="wp-image-4852 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/09/icons8-google-maps-180-e1537353957364.png" alt="" width="100" height="100" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/icons8-google-maps-180-e1537353957364.png 155w, https://zappysys.com/blog/wp-content/uploads/2018/09/icons8-google-maps-180-e1537353957364-150x150.png 150w" sizes="(max-width: 100px) 100vw, 100px" /></p>
<p style="text-align: justify;">In this tutorial, we will cover the topics of how to perform <em>geocoding</em> on the addresses and <em>reverse geocoding</em> on the location coordinates using SSIS and <a href="https://developers.google.com/maps/documentation/" rel="noopener">Google Maps API</a>. So what is <em>geocoding,</em> exactly? <em>Geocoding</em> is the process of translating an address (e.g. a street address) or a place to coordinates on the Earth&#8217;s surface. Simply put, <em>geocoding</em> takes a description of a location and gives back latitude and longitude values as a result. For example, <pre class="crayon-plain-tag">1600 Amphitheatre Parkway, Mountain View, CA 94043, USA</pre>  gets translated to <pre class="crayon-plain-tag">(37.4224764, -122.0842499)</pre>. <em>Reverse geocoding</em>, on the other hand, is the exact opposite process. In it, latitude and longitude values pair gets translated into a human-readable form. To take the same example above,  <pre class="crayon-plain-tag">(37.4224764, -122.0842499)</pre> would translate back to <pre class="crayon-plain-tag">1600 Amphitheatre Parkway, Mountain View, CA 94043, USA</pre>. So, if you need to perform any of the lookups, you can use <a href="https://developers.google.com/maps/documentation/geocoding/start" rel="noopener">Google Maps Geocoding API</a>. Actually, Google Maps Geocoding API offers a bit more <span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– you can use it for <em>address validation</em>, <em>cleansing</em>, and <em>formatting</em>.</span></span></span></span></p>
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE:</strong> If it happens that you need to use other geocoding provider and perform the lookups in SSIS, you may still benefit from this article (the examples of usage of Google Maps Geocoding API can be replaced by another provider). </div></div>
<p style="text-align: justify;">To accomplish our goal we will use an add-on for SSIS <span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– <a href="https://zappysys.com/products/ssis-powerpack/" rel="noopener">ZappySys SSIS PowerPack</a></span></span></span></span><span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">.</span></span></span></span> It contains many additional SSIS Tasks and Data Flow Components that lets you accomplish what you cannot do with standard SSIS connectors. We will use these <a href="https://zappysys.com/products/ssis-powerpack/" rel="noopener">ZappySys SSIS PowerPack</a> connectors:</p>
<div class="content_block" id="custom_post_widget-5067"><div style="display: table-row; background: #f7f7f7;">
<div style="display: table-cell; padding: 1em; border: 1px solid #ccc;"><img loading="lazy" decoding="async" style="vertical-align: middle; width: 50px; height: 50px; max-width: 50px;" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/web-api-destination/ssis-web-api-destination.png" alt="Web API Destination" width="50" height="50" /></div>
<div style="display: table-cell; padding: 1em; border: 1px solid #ccc; border-left: none; width: 100%;"><a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a></div>
</div></div>
<div class="content_block" id="custom_post_widget-5078"><div style="display: table-row; background: #f7f7f7;">
<div style="display: table-cell; padding: 1em; border: 1px solid #ccc;"><img loading="lazy" decoding="async" style="vertical-align: middle; width: 50px; height: 50px; max-width: 50px;" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-parser-transform/ssis-json-parser-transform.png" alt="JSON Parser Transform" width="50" height="50" /></div>
<div style="display: table-cell; padding: 1em; border: 1px solid #ccc; border-left: none; width: 100%;"><a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a></div>
</div></div>
<p>Let&#8217;s start!</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><span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS">Step-by-Step <span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– </span></span></span></span>SSIS Geocoding with Google Maps API</h2>
<p style="text-align: justify;">Before we start, let&#8217;s consider the use-case for our tutorial. Suppose, you have a CRM system filled with user-entered addresses of your leads. Since they are user-entered, it means that they can be incomplete, malformed, or just plain rubbish. Also, you have a marketing campaign and you want to send letters with offers to your leads so that they become your clients. Before sending them any letters, you have to make sure the addresses are valid and well-formed. You are also interested in the geographical location of your leads that you could do some business intelligence analysis on the coordinates of your leads and maybe future clientele. Here is where Geocoding API kicks in.</p>
<p style="text-align: justify;">Thus in this example, we will take various street addresses <span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– sometimes invalid, </span></span></span></span>incomplete or unformatted <span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– and submit them to Google Geocoding API for processing. </span></span></span></span><span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">As a result, we will get nicely formatted, cleansed, full addresses and their coordinates. We will take a look on how to determine if lookup worked successfully and to what extent you should trust Geocoding API&#8217;s response. Finally, we will save retrieved addresses and their individual components (e.g. street number, street name, city, country, etc.) to a SQL Server database table.</span></span></span></span></p>
<div class="content_block" id="custom_post_widget-5017"><h3>Create a Google project</h3>
First, to use a Google API, you need to have a Google project. Create one, if you don't have any or want to use a new project:
<ol>
 	<li>Go to <a href="https://console.cloud.google.com/home/dashboard" target="_blank" rel="noopener">Google Console</a> and click on the projects list:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4923" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list.png" alt="" width="603" height="243" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list.png 603w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list-300x121.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></li>
 	<li>Once a window opens, click "New Project":
<img loading="lazy" decoding="async" class="alignnone wp-image-4924 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-create-new-project-1-e1538487942630.png" alt="" width="731" height="258" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-create-new-project-1-e1538487942630.png 731w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-create-new-project-1-e1538487942630-300x106.png 300w" sizes="(max-width: 731px) 100vw, 731px" /></li>
 	<li>Give a name for the project and click "Create":
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4925" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-give-name-for-project.png" alt="" width="603" height="379" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-give-name-for-project.png 603w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-give-name-for-project-300x189.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></li>
 	<li>Wait a couple of minutes for the project to create.</li>
 	<li>Again, click on the projects drop-down list:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4926" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list-1.png" alt="" width="603" height="243" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list-1.png 603w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-project-list-1-300x121.png 300w" sizes="(max-width: 603px) 100vw, 603px" /></li>
 	<li>Finally, select the project you've just created:
<img loading="lazy" decoding="async" class="alignnone wp-image-4927 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-the-project-e1538487850139.png" alt="" width="721" height="355" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-the-project-e1538487850139.png 721w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-the-project-e1538487850139-300x148.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-the-project-e1538487850139-720x355.png 720w" sizes="(max-width: 721px) 100vw, 721px" /></li>
</ol></div>
<div class="content_block" id="custom_post_widget-5025"><h3>Enable billing for the project</h3>
Not all Google APIs are free. So you'll have to add billing for the project you have just created:
<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>: As of September 21, 2018, Google offers 300 USD credit for free (but you will still need to create a billing account).</div>
</div>
<ol>
 	<li>Visit <a href="https://console.cloud.google.com/project/_/billing/enable?redirect=https://developers.google.com/maps/documentation/geocoding/usage-and-billing?dialogOnLoad%3Dbilling-enabled" target="_blank" rel="noopener">Billing on Google Console</a> page.</li>
 	<li>Once it's opened, select the project:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4928" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-project-list.png" alt="" width="641" height="385" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-project-list.png 641w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-project-list-300x180.png 300w" sizes="(max-width: 641px) 100vw, 641px" /></li>
 	<li>Once a list of projects appears, select the one you created.</li>
 	<li>Then you will be prompted to create a billing account. Proceed to create one:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4929" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-create-account.png" alt="" width="514" height="202" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-create-account.png 514w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-billing-create-account-300x118.png 300w" sizes="(max-width: 514px) 100vw, 514px" /></li>
</ol></div>
<div class="content_block" id="custom_post_widget-5031"><h3>Enable Google API for your project</h3>
To use any Google API you must enable it for your project:
<ol>
 	<li>Visit <a href="https://console.cloud.google.com/apis" target="_blank" rel="noopener">Google APIs Dashboard</a> page.</li>
 	<li>Make sure your project is selected and then click "Enable APIs and services":
<img loading="lazy" decoding="async" class="alignnone wp-image-4931 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-enable-api-for-the-project-e1538488797230.png" alt="" width="718" height="272" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-enable-api-for-the-project-e1538488797230.png 718w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-enable-api-for-the-project-e1538488797230-300x114.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></li>
 	<li>Then in the box which appears, search for API you are interested in, e.g. "geocoding":
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4934" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-search-for-api-1.png" alt="" width="645" height="303" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-search-for-api-1.png 645w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-search-for-api-1-300x141.png 300w" sizes="(max-width: 645px) 100vw, 645px" /></li>
 	<li>Finally, click on the Google API (e.g. "Geocoding API") tile:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4935" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-geocoding-api.png" alt="" width="654" height="405" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-geocoding-api.png 654w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-select-geocoding-api-300x186.png 300w" sizes="(max-width: 654px) 100vw, 654px" /></li>
 	<li>Finally finally, enable Google API:
<img loading="lazy" decoding="async" class="alignnone wp-image-4936 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-enable-geocoding-api-e1537539131256.png" alt="" width="647" height="343" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-enable-geocoding-api-e1537539131256.png 647w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-api-console-enable-geocoding-api-e1537539131256-300x159.png 300w" sizes="(max-width: 647px) 100vw, 647px" /></li>
</ol></div>
<div class="content_block" id="custom_post_widget-5035"><h3>Create Geocoding API Key</h3>
Once you have Google API enabled, you are ready to create a Google API Key, which you will use in all HTTP requests:
<ol>
 	<li>Go to <a href="https://console.cloud.google.com/apis/dashboard" target="_blank" rel="noopener">Google APIs Dashboard</a>.</li>
 	<li>Make sure you have your project selected, then select "Credentials" menu item and create a new API Key:
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-4937" src="https://zappysys.com/blog/wp-content/uploads/2018/09/sssi-google-api-how-to-create-api-key.png" alt="" width="695" height="434" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/sssi-google-api-how-to-create-api-key.png 695w, https://zappysys.com/blog/wp-content/uploads/2018/09/sssi-google-api-how-to-create-api-key-300x187.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/09/sssi-google-api-how-to-create-api-key-436x272.png 436w" sizes="(max-width: 695px) 100vw, 695px" /></li>
 	<li>Copy the newly created API Key to a safe place; we will use it later.</li>
</ol></div>
<h3>Load addresses from a SQL Server database table</h3>
<p>We prepared the Google Geocoding API part, now we are ready to get to the place where the rubber meets the road <span id="Step-by-Step_Export_data_from_Salesforce_to_SQL_Server_using_SSIS"><span id="Step-by-Step_Get_data_from_HubSpot_API_into_SQL_Server_database"><span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– </span></span></span></span>we will create an SSIS package and load addresses from a database table:</p>
<ol>
<li>Create a new SSIS package.</li>
<li>Drag and drop <strong>Data Flow</strong> from SSIS Toolbox onto the Control Flow.
<div id="attachment_8028" style="width: 470px" class="wp-caption alignnone"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8028" class="size-full wp-image-8028" src="https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task.png" alt="" width="460" height="155" srcset="https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task.png 460w, https://zappysys.com/blog/wp-content/uploads/2019/02/drag-and-drop-data-flow-task-300x101.png 300w" sizes="(max-width: 460px) 100vw, 460px" /><p id="caption-attachment-8028" class="wp-caption-text">Dragging and dropping Data Flow Task into Control Flow</p></div></li>
<li>Drag and drop <strong>OLE DB Source</strong> onto the Data Flow.</li>
<li>Configure <strong>OLE DB Source</strong> to retrieve addresses from your table. We will use a table from Microsoft&#8217;s Northwind&#8217;s modified database &#8220;Marketing&#8221; (<a href="https://zappysys.com/blog/wp-content/uploads/2018/09/Marketing-database-script.zip">download it</a>):</li>
</ol>
<div id="attachment_4949" style="width: 718px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-load-addresses-1-e1538134305642.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4949" class="wp-image-4949 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-load-addresses-1-e1538134305642.png" alt="Loading user-entered addresses to be looked up in Google Geocoding API using SSIS." width="708" height="704" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-load-addresses-1-e1538134305642.png 708w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-load-addresses-1-e1538134305642-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-load-addresses-1-e1538134305642-300x298.png 300w" sizes="(max-width: 708px) 100vw, 708px" /></a><p id="caption-attachment-4949" class="wp-caption-text">Loading user-entered addresses to be looked up in Google Geocoding API using SSIS.</p></div>
<h3>Construct lookup URL</h3>
<ol>
<li>Drag and drop <strong>Derived Column</strong> component onto the Data Flow.</li>
<li>Add a new column and construct Geocoding lookup URL in this format (just like it says in <a href="https://developers.google.com/maps/documentation/geocoding/start" rel="noopener">Geocoding API documentation</a>):</li>
</ol>
<pre class="crayon-plain-tag">https://maps.googleapis.com/maps/api/geocode/json?address=ADDRESS_TO_LOOKUP&amp;key=YOUR_API_KEY</pre>
<div id="attachment_4959" style="width: 729px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-construct-url-e1538140223385.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4959" class="wp-image-4959 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-construct-url-e1538140223385.png" alt="Adding Google Geocoding API lookup URL as Derived Column to be used for geocoding in SSIS." width="719" height="510" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-construct-url-e1538140223385.png 719w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-construct-url-e1538140223385-300x213.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></a><p id="caption-attachment-4959" class="wp-caption-text">Adding Google Geocoding API lookup URL as Derived Column to be used for geocoding in SSIS.</p></div>
<h3>Configure the Geocoding API request</h3>
<ol>
<li>Drag and drop <strong>Web API Destination</strong> onto the Data Flow and connect it with Derived Column. We will use Web API Destination to make HTTP requests to Geocoding API.</li>
<li>Then double-click on Web API Destination and create a new HTTP connection:
<div id="attachment_4962" style="width: 796px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-create-http-connection.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4962" class="wp-image-4962 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-create-http-connection.png" alt="Setting up HTTP Connection Manager for Web API Destination to make HTTP requests to Google Geocoding API using SSIS." width="786" height="478" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-create-http-connection.png 786w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-create-http-connection-300x182.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-create-http-connection-768x467.png 768w" sizes="(max-width: 786px) 100vw, 786px" /></a><p id="caption-attachment-4962" class="wp-caption-text">Setting up HTTP Connection Manager for Web API Destination to make HTTP requests to Google Geocoding API using SSIS.</p></div></li>
<li>Finally, configure <em>Input Column for URL</em>, <em>HTTP Request Method</em> and input into URL field a sample lookup URL:<br />
<pre class="crayon-plain-tag">https://maps.googleapis.com/maps/api/geocode/json?address=One Microsoft Way Redmond 98052-6399 USA&amp;key=YOUR_API_KEY</pre>
<div id="attachment_4963" style="width: 711px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-web-api-destination.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4963" class="wp-image-4963 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-web-api-destination.png" alt="Configuring Web API Destination to make geocoding lookups in Google Geocoding API using SSIS." width="701" height="623" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-web-api-destination.png 701w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-web-api-destination-300x267.png 300w" sizes="(max-width: 701px) 100vw, 701px" /></a><p id="caption-attachment-4963" class="wp-caption-text">Configuring Web API Destination to make geocoding lookups in Google Geocoding API using SSIS.</p></div>
<p>Once you are done, click <strong>Test Request/Response</strong> button. This will actually make a geocoding lookup for Microsoft headquarters:</li>
<li>In the <em>Response (Raw)</em> tab you see the actual response from Geocoding API. Within it –  cleansed, formatted and full Microsoft headquarters address together with geographical coordinates (even we looked it up using just the part of it). Now copy-paste the response body somewhere, so that we can use it in the next step while parsing:
<div id="attachment_4964" style="width: 693px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-sample-response.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4964" class="wp-image-4964 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-sample-response.png" alt="Checking Google Geocoding API HTTP response in Web API Destination using SSIS." width="683" height="642" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-sample-response.png 683w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-sample-response-300x282.png 300w" sizes="(max-width: 683px) 100vw, 683px" /></a><p id="caption-attachment-4964" class="wp-caption-text">Checking Google Geocoding API HTTP response in Web API Destination using SSIS.</p></div></li>
</ol>
<div class="su-note"  style="border-color:#e5da9d;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:#fff4b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE:</strong> When Google Geocoding API retrieves only a partial result, it adds a new property in JSON named <em>partial_match</em>, as described in <a href="https://developers.google.com/maps/documentation/geocoding/intro#Results" rel="noopener">Geocoding API documentation</a>. This node is not present in the above sample response. </div></div>
<h3>Parsing Geocoding API JSON response into columns</h3>
<ol>
<li>Drag and drop <strong>JSON Parser Transform</strong> onto the Data Flow and connect it to Web API Destination.</li>
<li>Then open it and configure <em>Input JSON Column</em>.</li>
<li>After that, set the <em>Filter</em> to <strong>$.results[*]</strong>.</li>
<li>Continue by setting <em>Sample JSON strin</em>g to the one you saved in the previous step. Actually, before doing that let&#8217;s modify it and add <strong>partial_match</strong> node next to <strong>place_id</strong> so that <em>exact</em> and <em>partial</em> matches could be told apart (otherwise this property won&#8217;t be parsed):<br />
<pre class="crayon-plain-tag">{
    "results": [{
        "address_components": [{
            "long_name": "One",
            "short_name": "One",
            "types": ["street_number"]
        }, {
            "long_name": "Microsoft Way",
            "short_name": "Microsoft Way",
            "types": ["route"]
        }, {
            "long_name": "Overlake",
            "short_name": "Overlake",
            "types": ["neighborhood", "political"]
        }, {
            "long_name": "Redmond",
            "short_name": "Redmond",
            "types": ["locality", "political"]
        }, {
            "long_name": "King County",
            "short_name": "King County",
            "types": ["administrative_area_level_2", "political"]
        }, {
            "long_name": "Washington",
            "short_name": "WA",
            "types": ["administrative_area_level_1", "political"]
        }, {
            "long_name": "United States",
            "short_name": "US",
            "types": ["country", "political"]
        }, {
            "long_name": "98052",
            "short_name": "98052",
            "types": ["postal_code"]
        }],
        "formatted_address": "One Microsoft Way, Redmond, WA 98052, USA",
        "geometry": {
            "location": {
                "lat": 47.6423318,
                "lng": -122.1369302
            },
            "location_type": "ROOFTOP",
            "viewport": {
                "northeast": {
                    "lat": 47.6436807802915,
                    "lng": -122.1355812197085
                },
                "southwest": {
                    "lat": 47.6409828197085,
                    "lng": -122.1382791802915
                }
            }
        },
        "partial_match": false,
        "place_id": "ChIJGxUEuHFtkFQRnokD7mkppQE",
        "plus_code": {
            "compound_code": "JVR7+W6 Redmond, Washington, United States",
            "global_code": "84VVJVR7+W6"
        },
        "types": ["establishment", "point_of_interest"]
    }],
    "status": "OK"
}</pre>
<div id="attachment_4967" style="width: 729px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-json-parser-transform-1.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4967" class="wp-image-4967 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-json-parser-transform-1.png" alt="Configuring JSON Parser Transform to parse looked up addresses in Google Geocoding API HTTP JSON response using SSIS." width="719" height="584" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-json-parser-transform-1.png 719w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-json-parser-transform-1-300x244.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></a><p id="caption-attachment-4967" class="wp-caption-text">Configuring JSON Parser Transform to parse looked up addresses in Google Geocoding API HTTP JSON response using SSIS.</p></div></li>
<li>To proceed and parse <em>individual address components</em> from JSON response (e.g. number, street, city, country, etc.), you will need to specify columns for each address component manually, just like portrayed in <a href="https://zappysys.com/blog/parse-multi-dimensional-json-array-ssis/#Pattern_5_8211_Multiple_Columns_with_Expressions_Google_Geocoding_API_Usecase" rel="noopener">Parse multi-dimensional JSON array in SSIS or Drivers</a> article. Just open <em>2D Array Transform</em> tab and select <strong>Multiple columns using expressions</strong> as <em>Transform Type</em> and configure them:
<div id="attachment_4970" style="width: 716px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-columns-json-parser-transform-1.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4970" class="wp-image-4970 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-columns-json-parser-transform-1.png" alt="Configuring JSON Parser Transform to parse individual address components from Google Geocoding API HTTP JSON response using SSIS." width="706" height="739" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-columns-json-parser-transform-1.png 706w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-configure-columns-json-parser-transform-1-287x300.png 287w" sizes="(max-width: 706px) 100vw, 706px" /></a><p id="caption-attachment-4970" class="wp-caption-text">Configuring JSON Parser Transform to parse individual address components from Google Geocoding API HTTP JSON response using SSIS.</p></div>
<p>We specify these columns in our example:</p><pre class="crayon-plain-tag">Number = $.address_components[?(@.types[0]=='street_number')].long_name
Street = $.address_components[?(@.types[0]=='route')].long_name
City = $.address_components[?(@.types[0]=='locality')].long_name
State = $.address_components[?(@.types[0]=='administrative_area_level_1')].long_name
Country = $.address_components[?(@.types[0]=='country')].long_name
PostalCode = $.address_components[?(@.types[0]=='postal_code')].long_name</pre><p>
</li>
<li>Finally, be sure to set <strong>Include all upstream columns to downstream</strong> (quite important), so that CustomerID is passed downstream and which we can save into a destination table. Later it can be a useful column to join the source table and the destination table on. In that way, you will be able to map user-entered addresses with looked up, fully formatted addresses (won&#8217;t be demonstrated in this tutorial).</li>
</ol>
<h3>Save geocoding results into a SQL Server database table</h3>
<ol>
<li>We are now ready to add <strong>OLE DB Destination</strong>, execute the package, make the lookups, and save the results into the database:
<div id="attachment_4971" style="width: 828px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-saving-results-into-ole-db-destination-e1538150325533.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4971" class="wp-image-4971 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-saving-results-into-ole-db-destination-e1538150325533.png" alt="Creating a database table for the Google Geocoding API looked up addresses in SSIS." width="818" height="727" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-saving-results-into-ole-db-destination-e1538150325533.png 818w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-saving-results-into-ole-db-destination-e1538150325533-300x267.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-saving-results-into-ole-db-destination-e1538150325533-768x683.png 768w" sizes="(max-width: 818px) 100vw, 818px" /></a><p id="caption-attachment-4971" class="wp-caption-text">Creating a database table for the Google Geocoding API looked up addresses in SSIS.</p></div></li>
<li>Execute the package!
<div id="attachment_4972" style="width: 705px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-lookup-results.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4972" class="wp-image-4972 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-lookup-results.png" alt="SSIS geocoding package execution and its results." width="695" height="471" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-lookup-results.png 695w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-lookup-results-300x203.png 300w" sizes="(max-width: 695px) 100vw, 695px" /></a><p id="caption-attachment-4972" class="wp-caption-text">SSIS geocoding package execution and its results.</p></div></li>
</ol>
<h3>The results of SSIS geocoding</h3>
<div id="attachment_4985" style="width: 614px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4985" class="wp-image-4985 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis.png" alt="Viewing the results of SSIS geocoding in SQL Server destination table." width="604" height="209" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis.png 604w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis-300x104.png 300w" sizes="(max-width: 604px) 100vw, 604px" /></a><p id="caption-attachment-4985" class="wp-caption-text">Viewing the results of SSIS geocoding in SQL Server destination table.</p></div>
<p style="text-align: justify;">Once you query the table of looked up results, you will notice several things:</p>
<ol style="text-align: justify;">
<li>Perhaps there are more rows in the results table than in the source table</li>
<li><em>partial_match</em> column is either <strong>1</strong> or <strong>NULL</strong></li>
<li><em>geometry.location_type </em>column has several values, e.g. <strong>ROOFTOP</strong>, <strong>RANGE_INTERPOLATED</strong>, <strong>APPROXIMATE</strong>, etc.</li>
</ol>
<p style="text-align: justify;">So to what extent should you trust the results? The answer is to take a look at <a href="https://developers.google.com/maps/documentation/geocoding/intro#Results" rel="noopener">the documentation</a> and see what these values mean.</p>
<p style="text-align: justify;">Basically, when <em>partial_match</em> is equal to <strong>1</strong>, according to Google:</p>
<ul style="text-align: justify;">
<li>Partial matches most often occur for street addresses that do not exist within the locality you pass in the request.</li>
<li>Partial matches may also be returned when a request matches two or more locations in the same locality. For example, &#8220;21 Henr St, Bristol, UK&#8221; will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.</li>
</ul>
<p style="text-align: justify;">While <em>geometry.location_type</em> column tells how accurate the lookup was. Again, according to Google:</p>
<ul style="text-align: justify;">
<li><strong>&#8220;ROOFTOP&#8221;</strong> indicates that the returned result is a precise geocode for which we have location information accurate down to street address precision.</li>
<li><strong>&#8220;RANGE_INTERPOLATED&#8221;</strong> indicates that the returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.</li>
<li><strong>&#8220;GEOMETRIC_CENTER&#8221;</strong> indicates that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).</li>
<li><strong>&#8220;APPROXIMATE&#8221;</strong> indicates that the returned result is approximate.</li>
</ul>
<p style="text-align: justify;">Simply put, <strong>&#8220;ROOFTOP&#8221;</strong> is the most accurate lookup, while <strong>&#8220;APPROXIMATE&#8221;</strong> is the least accurate.</p>
<p style="text-align: justify;">Another valuable piece of information is how many individual address components are filled. The more <strong>NULLs</strong> are there, the less accurate is the address. So if you have <strong>NULL</strong> in the <em>Number</em> column and in the <em>Street</em> column, most likely this is not a very accurate lookup:</p>
<div id="attachment_4987" style="width: 675px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis2.png" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4987" class="wp-image-4987 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis2.png" alt="Individual address components of looked up addresses in Google Geocoding API using SSIS." width="665" height="210" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis2.png 665w, https://zappysys.com/blog/wp-content/uploads/2018/09/ssis-google-geocoding-api-result-analysis2-300x95.png 300w" sizes="(max-width: 665px) 100vw, 665px" /></a><p id="caption-attachment-4987" class="wp-caption-text">Individual address components of looked up addresses in Google Geocoding API using SSIS.</p></div>
<p style="text-align: justify;">Concluding, in the figure above, you can see how user-entered address can be <em>validated</em>, <em>cleansed</em> and <em>formatted</em>.</p>
<h2>SSIS reverse geocoding with Google Maps API</h2>
<p>The concepts presented above about &#8220;forward&#8221; geocoding will help you to make reverse geocoding requests too. The only difference is the request URL:</p><pre class="crayon-plain-tag">https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&amp;key=YOUR_API_KEY</pre><p>
For reference and help visit official <a href="https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding" rel="noopener">Google Geocoding API documentation</a>.</p>
<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>Common errors</h2>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2><span id="Deployment_to_Production">Parameterization and d</span><span id="Deployment_to_Production">eployment to production </span></h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<h2>Download a sample package</h2>
<p style="text-align: justify;">Be sure to download a <a href="https://zappysys.com/blog/wp-content/uploads/2018/09/SSIS-Geocoding-using-Google-Maps-API.zip">sample SQL Server 2012 SSIS package</a>, in case you want to try it right away (you can upgrade it to a higher version). If you want to use the database that was used in this tutorial, don&#8217;t forget to create the <a href="https://zappysys.com/blog/wp-content/uploads/2018/09/Marketing-database-script.zip">Marketing database from the script</a> (a modified Microsoft&#8217;s Northwind database).</p>
<h2>Conclusion</h2>
<p style="text-align: justify;">In this tutorial, we step-by-step covered how to make geocoding lookups using Geocoding API, part of Google Maps API. We learned how to <em>cleanse</em>, <em>validate</em> and <em>format</em> address just by submitting it to Geocoding API and parsing the results. We moved forward and looked at how to interpret the results and what geocoding results to trust. Then we touched the point that the same process could be applied to <a href="https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding" rel="noopener"><em>reverse geocoding</em></a>. Concluding, we took a look at how to handle common errors and how to parameterize an SSIS package and deploy it to production.</p>
<p>The post <a href="https://zappysys.com/blog/ssis-geocoding-with-google-maps-api/">SSIS Geocoding with Google Maps API</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to read / write data in Google BigQuery using SSIS</title>
		<link>https://zappysys.com/blog/get-data-google-bigquery-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sun, 16 Jul 2017 01:10:44 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Generator Transform]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS WEB API Destination]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[big data]]></category>
		<category><![CDATA[fiddler]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[Google BigQuery]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis json source]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis web api destination]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1563</guid>

					<description><![CDATA[<p>Introduction Google BigQuery is a fully managed Big Data platform to run queries against large scale data. In this article you will learn how to integrate Google BigQuery data into Microsoft SQL Server using SSIS. We will leverage highly flexible JSON based REST API Connector and OAuth Connection to import / export data from Google [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/get-data-google-bigquery-using-ssis/">How to read / write data in Google BigQuery using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>UPDATE:</strong> ZappySys has released a brand new <a href="https://zappysys.com/api/integration-hub/google-bigquery-connector/">API Connector for BigQuery Online</a> which makes it much simpler to <strong>Read/Write BigQuery 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>
<p style="text-align: left;"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/google-big-query-integration-1.png"><img loading="lazy" decoding="async" class="alignleft wp-image-1959" src="//zappysys.com/blog/wp-content/uploads/2017/07/google-big-query-integration-1-150x150.png" alt="Google BigQuery API Integration" width="91" height="91" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/google-big-query-integration-1-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/07/google-big-query-integration-1.png 257w" sizes="(max-width: 91px) 100vw, 91px" /></a><a href="https://cloud.google.com/bigquery/" target="_blank" rel="noopener">Google BigQuery</a> is a fully managed <strong>Big Data platform</strong> to run queries against large scale data. In this article you will learn how to integrate <strong>Google BigQuery</strong> data into <strong>Microsoft SQL Server</strong> using <strong>SSIS</strong>. We will leverage highly flexible <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">JSON based REST API Connector</a> and <strong>OAuth Connection</strong> to import / export data from <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/" target="_blank" rel="noopener">Google BigQuery API</a> just in a few clicks.</p>
<p style="text-align: left;">If you are looking for a similar product inside Amazon AWS Cloud then <a href="https://zappysys.com/blog/import-export-data-amazon-athena-using-ssis/" target="_blank" rel="noopener">check an article about Amazon Athena</a>.</p>
<h2><span id="Prerequisites">Prerequisites</span></h2>
<p>Before we look into a Step-By-Step section to extract and load data from BigQuery to SQL Server let&#8217;s make sure you meet the following requirements:</p>
<ol>
<li>SSIS designer installed. Sometimes it is referred as BIDS or SSDT (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from Microsoft site</a>).</li>
<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
<li><a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener"><em>ZappySys SSIS PowerPack</em> installed</a>. Click on the link to download a FREE trial.</li>
<li>You have basic familiarity with REST API concepts and Google BigQuery API. This post uses <a href="https://cloud.google.com/bigquery/public-data/" target="_blank" rel="noopener">free Public Dataset</a> to query BigQuery table so <em>no billing</em> is required to get your hands dirty 🙂 However, if you like to query your own dataset then make sure you have at least one BigQuery dataset and one table with some sample data created (this part <em>does require</em> billing enabled). Read a <a href="https://cloud.google.com/bigquery/quickstart-web-ui" target="_blank" rel="noopener">Google Quickstart article</a> for more information on how to create a new BigQuery dataset and a table.</li>
</ol>
<h2>Understanding Google BigQuery Object Heirarchy</h2>
<p>Google BigQuery has 3 main concepts below.</p>
<ul style="list-style-type: circle;">
<li>Project
<ul style="list-style-type: circle;">
<li>Dataset
<ul style="list-style-type: circle;">
<li>Table
<ul style="list-style-type: circle;">
<li>Query requests (each query creates a unique JobID &#8211; valid for 24 hours from which you can read data)</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>So in order to create BigQuery table you always need Project and then Dataset under that project. You can group objects around Project / Datasets. When you query you can supply fully qualified name of your table in FROM clause (e.g. <pre class="crayon-plain-tag">select count(*) from `bigquery-public-data.usa_names.usa_1910_2013`</pre>  Here <strong>bigquery-public-data</strong> is project name, <strong>usa_names</strong> is dataset and <strong>usa_1910_2013</strong>  is table). So lets get started with Read operation first and then we will cover write operation. For Read operation we will use public dataset so we can quickly show you demo without too many steps but later we will cover how to automate create / delete of Dataset / Tables using API calls.</p>
<p>So let&#8217;s get started.</p>
<h2>Read data from Google BigQuery using SSIS</h2>
<p>Basically you can query Google BigQuery data in two ways: In this article we will not cover 2nd method.</p>
<ul>
<li><strong>Method-1</strong>: Query data using <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query" target="_blank" rel="noopener"><em>jobs/query</em> method in BigQuery API</a>. Use it if you expect to get a result in a fairly short amount of time. This API method generates a temp table which gets deleted after 24 hours. You can read data within that time frame using newly created <em>JobId</em> reference.<br />
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE:</strong> If you have records that sum up to more than 10MB of data or ~10,000 rows (assuming 1 row uses 1KB of data) then you need to proceed with two-step process as explained below.</div></div></li>
<li><strong>Method-2</strong>: Export SQL query result using <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert" target="_blank" rel="noopener"><em>jobs/insert</em> method in BigQuery API</a>. Use this method if you expect a query to take a long time to finish.</li>
</ul>
<p>Now let&#8217;s see how to query Google BigQuery data using SSIS 🙂</p>
<h3>Create Google API Project and Register OAuth App</h3>
<p>To use any <a href="https://developers.google.com/apis-explorer/#p/" target="_blank" rel="noopener">Google API</a> firstly you have to finish two tasks:</p>
<ol>
<li><a href="//zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Create Google API Project</a> and obtain projectId (see next section).</li>
<li><a href="https://console.cloud.google.com/apis/library/bigquery.googleapis.com" target="_blank" rel="noopener">Enable BigQuery API</a></li>
<li>Register your own Google OAuth App and obtain <strong>ClientId</strong> and <strong>Client Secret</strong>.</li>
</ol>
<p>Check step-by-step instructions on <a href="//zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">how to create Google API Project and create OAuth App for Google</a>. During instructions make sure you enable BigQuery API (screenshots may differ).</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;">NOTE: For BigQuery API you must use custom app option on OAuth connection. Google used to allow Default App but recent policy changes requires BigQuery to use Custom App to obtain your own ClientId and Client Secret (Some old Screenshots may use Default App for time being so please adjust your settings to use Custom App)</div></div>
<h3>Get Google API Project ID</h3>
<p>Once you have Google API Project created you can grab <a href="https://console.cloud.google.com/project?_ga=1.106484547.1991223081.1500069328">Project ID</a> (see screenshot below). You will need Project ID in the next step when building API URL.</p>
<div id="attachment_1567" style="width: 583px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/how-to-find-google-api-project-id.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1567" class="size-full wp-image-1567" src="//zappysys.com/blog/wp-content/uploads/2017/07/how-to-find-google-api-project-id.png" alt="How to find Google API Project ID" width="573" height="379" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/how-to-find-google-api-project-id.png 573w, https://zappysys.com/blog/wp-content/uploads/2017/07/how-to-find-google-api-project-id-300x198.png 300w" sizes="(max-width: 573px) 100vw, 573px" /></a><p id="caption-attachment-1567" class="wp-caption-text">How to find Google API Project ID?</p></div>
<h3>Configure OAuth Connection for Google BigQuery API</h3>
<p>In order to call most of Google APIs you will need an OAuth App. If you want to use your own app then refer to <a href="//zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">how to register Google OAuth Application (Get ClientID and ClientSecret)</a> article. For simplicity we will use <em>Default OAuth App</em>:</p>
<ol style="margin-left: 0;">
<li>Right click inside Connection Managers area and click &#8220;New Connection&#8230;&#8221;</li>
<li>From the connection type list select &#8220;ZS-OAUTH&#8221; connection type.
<div id="attachment_1569" style="width: 687px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1569" class="size-full wp-image-1569" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png" alt="Create new SSIS OAuth API Connection Manager" width="677" height="220" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png 677w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection-300x97.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a><p id="caption-attachment-1569" class="wp-caption-text">Create new SSIS OAuth API Connection Manager</p></div></li>
<li>For OAuth Provider select &#8220;Google&#8221;.</li>
<li>For OAuth App type options leave &#8220;Use Default OAuth App&#8221; selected. If you <a href="//zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">created custom OAuth App</a> then you would need to select &#8220;Use Custom OAuth App&#8221; option.</li>
<li>For Scopes enter or select the following URLs (URL is just a permission name). Each URL must be in a separate line. For demo purposes we use only the first 3 scopes but we included a few more in case you like to test API in depth with a different permission set:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/bigquery
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/cloud-platform.read-only
https://www.googleapis.com/auth/bigquery.insertdata
https://www.googleapis.com/auth/devstorage.full_control
https://www.googleapis.com/auth/devstorage.read_only
https://www.googleapis.com/auth/devstorage.read_write</pre>
</li>
<li>Click Generate Token. Login using correct account if needed and then you will be prompted to click &#8220;Approve&#8221; OAuth App.</li>
<li>Once you click OK on the login screen you will see new tokens populated on the connection screen.</li>
<li>Click Test to make sure connection / tokens are valid and then click OK to save the connection.<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>NOTE:</strong> Below screenshot uses Default App but we recommend you to to use Custom OAuth App (Your own Clientid / secret &#8211; Obtained in previous section)</div></div>
<div id="attachment_1568" style="width: 685px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-integration-oauth-api-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1568" class="size-full wp-image-1568" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-integration-oauth-api-connection.png" alt="Create SSIS OAuth API Connection for Google BigQuery API" width="675" height="654" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-integration-oauth-api-connection.png 675w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-integration-oauth-api-connection-300x291.png 300w" sizes="(max-width: 675px) 100vw, 675px" /></a><p id="caption-attachment-1568" class="wp-caption-text">Create SSIS OAuth API Connection for Google BigQuery API</p></div></li>
</ol>
<h3>Start BigQuery Job and get JobId (Submit Query)</h3>
<p>Once you have SSIS OAuth connection created for BigQuery API it&#8217;s time to read data from BigQuery. So, basically, there are two ways you can read BigQuery data: using <em>query </em>or <em>insert </em>method. For demo purposes we will use <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query" target="_blank" rel="noopener"><em>jobs/query</em> method</a>. If you want fire complex queries which can run for many minutes then refer to <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert" target="_blank" rel="noopener"><em>jobs/insert</em> method</a>.</p>
<p>If you are expecting more than 10MB of data (~10K records) then you have to split data extract in two steps:</p>
<ol>
<li>Step-1 : Call <em>jobs/query</em> method using REST API Task to submit SQL query. This steps returns <strong>jobComplete: true</strong> if supplied query execution is done within timeoutMs parameter you included. By default its 10 seconds so if your query is going to take longer than 10 seconds then its good idea to add bigger timeout that way you dont need <strong>step#2</strong>. Once API call is done you will Get JobId in the response. Save that JobId in a variable for later use. This job result is valid for 24-hours only.</li>
<li>Step-2 <strong>(Optional)</strong> &#8211; You can add another optional <strong>REST API Task</strong> after previous step to Wait until Job is completed. For simplicity, this article will Omit setting up Status Check but its very simple&#8230;.Use below settings
<ol>
<li>Drag new REST API Task from toolbox. Connect it to Step-1 and double click to configure as below.</li>
<li>Select URL From Connection mode,</li>
<li>Select OAuth connection</li>
<li>Enter URL as <strong>https://www.googleapis.com/bigquery/v2/projects/{{User::ProjectId}}/jobs/{{User::JobId}}</strong> , Method: <strong>GET</strong></li>
<li>On Response Settings Tab, Select Response Content Type <strong>JSON</strong> and for content filter enter <strong>$.status.state</strong></li>
<li>On Status Check Tab, check Enable Status Check Loop and enter <strong>DONE</strong> in SuccessValue field</li>
<li>Doing this setup will make sure we do not query data until Job Status is DONE (System keeps checking every 5 seconds)</li>
</ol>
</li>
<li>Step-2 : Read Job result using JSON Source in a Data Flow Task.</li>
</ol>
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE</strong> : If you are expecting less than ~10K rows then you can skip this step and just go to the next section &#8211; <a href="#Read_BigQuery_SQL_result_Method1_or_Method2">Read BigQuery SQL result (Method#1 or Method#2)</a>.</div></div>
<p>Now lets see how to configure REST API Task to submit query and extract JobId (which will be used in next section).</p>
<ol style="margin-left: 0;">
<li>In the Control Flow designer drag and drop <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">ZS REST API Task</a> from the SSIS toolbox.</li>
<li>Double click the task to configure it.</li>
<li>Change Request URL Access Mode to [Url from connection].</li>
<li>From the connection dropdown select OAuth connection created in the previous section.</li>
<li>Enter URL as below (replace YOUR-PROJECT-ID with a valid Project ID obtained in the previous section):<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/bigquery/v2/projects/YOUR-PROJECT-ID/queries</pre>
</li>
<li>Select Method as POST.</li>
<li>Enter Body (Request Data) as below (change your query if needed; we used Public dataset for the demo): If you do not specify timeout then default is 10 seconds only. Also in this call we only care about JobID from response so we just added maxResults=10 because in 2nd step we will get all rows by doing pagination.<br />
<pre class="crayon-plain-tag">{
   "timeoutMs": 100000, 
   "maxResults": 10, 
   "query": "SELECT title id,language,wp_namespace,reversion_id ,comment ,num_characters FROM [bigquery-public-data:samples.wikipedia] LIMIT 100000"
}</pre>
To use a <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/" target="_blank" rel="noopener">Standard SQL</a> query instead of <a href="https://cloud.google.com/bigquery/docs/reference/legacy-sql" target="_blank" rel="noopener">Legacy SQL</a>, add <strong>useLegacySql</strong> property and set it to <strong>false</strong>:<br />
<pre class="crayon-plain-tag">{
   "timeoutMs": 100000, 
   "maxResults": 10, 
   "query": "SELECT title id,language,wp_namespace,reversion_id ,comment ,num_characters FROM [bigquery-public-data:samples.wikipedia] LIMIT 100000",
   "useLegacySql": false
}</pre>
For all possible parameters refer to <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query" target="_blank" rel="noopener"><em>jobs/query</em> method documentation</a>.</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;"><strong>NOTE:</strong> You can also supply location Parameter in the Body JSON to indicate where job should run. For non EU / US datacenters we suggest you to supply this parameter. See details at <a href="https://cloud.google.com/bigquery/docs/locations#specifying_your_location" target="_blank" rel="noopener">https://cloud.google.com/bigquery/docs/locations#specifying_your_location</a>.<br />
Example Use Of Location<br />
<pre class="crayon-plain-tag">{ &quot;location&quot;:&quot;us-east1&quot;,&nbsp; &quot;maxResults&quot;: 10, &quot;query&quot;: &quot;SELECT title FROM [bigquery-public-data:samples.wikipedia] LIMIT 10&quot; }</pre>
</div></div></li>
<li>Select Body Content Type as <strong>application/json</strong>.</li>
<li>Click Test Request/Response. If things go well you will see JSON content. Then just <strong>copy JobId from the response</strong> and save for later use:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-rest-api-get-jobid.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2213" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-rest-api-get-jobid.png" alt="" width="677" height="488" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-rest-api-get-jobid.png 677w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-rest-api-get-jobid-300x216.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a></li>
<li>Now go to Response Settings tab.</li>
<li>Select ContentType=Json.</li>
<li>Enter below expression to extract JobId from the response. You will need this Id to read SQL query output (this JobId is valid for 24 hrs):<br />
<pre class="crayon-plain-tag">$.jobReference.jobId</pre>
</li>
<li>Choose save response content to save to a variable. Select &lt;New Variable&#8230;&gt; option. When prompted give a name to your variable (i.e. vJobId) and for the value field paste JobId copied from the above step:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-response-save-json-value-variable.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2214" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-response-save-json-value-variable.png" alt="" width="625" height="531" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-response-save-json-value-variable.png 625w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-response-save-json-value-variable-300x255.png 300w" sizes="(max-width: 625px) 100vw, 625px" /></a><br />
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE</strong>: This JobId expires after 24-hrs so while you are designing a package and not running it then design time value is used for testing/previewing. So make sure your JobId is valid. If needed click Test Request/Response to grab a new JobId and update the variable with a new value so you can preview data without running a full package.</div></div></li>
<li>Click OK to save the UI.</li>
</ol>
<h3>Read BigQuery SQL result (for specified JobID)</h3>
<p>Now let&#8217;s look at how to read data from BigQuery</p>
<p>Configure Google BigQuery Web Request (URL, Method, ContentType, Body etc.)</p>
<ol>
<li>In the Control Flow designer drag and drop 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 Data Flow Task and drag and drop <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">ZS JSON Source (For API/File)</a> from SSIS toolbox.<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 to edit and configure as below</li>
<li>Enter URL as below. Replace <strong>YOUR-API-PROJECT-ID</strong> with the API Project ID obtained in the <a href="//zappysys.com/blog/wp-content/uploads/2017/07/how-to-find-google-api-project-id.png" target="_blank" rel="noopener">previous section</a>.<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/bigquery/v2/projects/YOUR-API-PROJECT-ID/queries/{{User::vJobId}}?maxResults=10000</pre>
&#8211;OR&#8211; (Use below if your Job ran <strong>outside US / EU data center</strong>)<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/bigquery/v2/projects/YOUR-API-PROJECT-ID/queries/{{User::vJobId}}?location=YOUR_REGION_ID&amp;maxResults=10000</pre>
<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>NOTE:</strong> location Parameter indicates the geographic location of the job. This is <span style="text-decoration: underline;"><strong>Required parameter except for US and EU</strong></span>. See details at <a href="https://cloud.google.com/bigquery/docs/locations#specifying_your_location">https://cloud.google.com/bigquery/docs/locations#specifying_your_location</a>. You can supply same location parameter for first step when you <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query" target="_blank" rel="noopener">submit the query</a></p>
<p>Failure to supply location parameter for non US /EU users may result in <strong>404 NotFound Error</strong>.<br />
</div></div></li>
<li>Check <strong>Use Credentials</strong> option and select <strong>OAuth Connection Manager</strong> created in the previous section.</li>
<li>For HTTP Request Method select <strong>GET</strong>.<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-read-data-from-google-bigquery-job-use-json-source.png"><img loading="lazy" decoding="async" class="size-full wp-image-2215" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-read-data-from-google-bigquery-job-use-json-source.png" alt="Read data from Google BigQuery from Temp Job result" width="1004" height="661" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-read-data-from-google-bigquery-job-use-json-source.png 1004w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-read-data-from-google-bigquery-job-use-json-source-300x198.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-read-data-from-google-bigquery-job-use-json-source-768x506.png 768w" sizes="(max-width: 1004px) 100vw, 1004px" /></a></li>
</ol>
<p>Read data from Google BigQuery from Temp Job result</p>
<h4>Configure Filter</h4>
<p>We need to transform a single JSON response into multiple rows so we need to apply a correct filter.</p>
<ol>
<li>On JSON Source go to Filter Options tab.</li>
<li>In the Filter field enter<strong> $.rows[*]</strong> or click [Select Filter] button to browse hierarchy you want to extract.</li>
</ol>
<div id="attachment_1573" style="width: 685px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-get-data-google-bigquery-select-json-filter.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1573" class="wp-image-1573 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-get-data-google-bigquery-select-json-filter.png" alt="Select Filter for JSON Response" width="675" height="363" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-get-data-google-bigquery-select-json-filter.png 675w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-get-data-google-bigquery-select-json-filter-300x161.png 300w" sizes="(max-width: 675px) 100vw, 675px" /></a><p id="caption-attachment-1573" class="wp-caption-text">Select Filter for JSON Response</p></div>
<h4>Configure BigQuery API Pagination Settings</h4>
<p>Most of modern APIs usually implement some sort of pagination technique so you get a part of data in each request rather than all in one go. Thus if you want more you can paginate through pages until the last page is reached. You can also read <a href="//zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">Understanding REST API Pagination in SSIS</a> article to learn more about pagination in SSIS.</p>
<p>BigQuery API returns <em>pageToken</em> attribute in response JSON if more data is found for requested query result. You can then pass <em>pageToken</em> in the next URL in this format: <strong>http://my-api-url/?pageToken=xxxxxxxxxx</strong></p>
<p>Now lets configure JSON Source to automate this pagination for us. On JSON Source go to Pagination Tab and enter the following two settings:</p>
<ol>
<li>Set Next Link as <strong>$.pageToken</strong>.</li>
<li>Set Suffix for Next URL as <strong>&amp;pageToken=&lt;%nextlink%&gt;</strong>.</li>
</ol>
<p>See the screenshot below to get more clarity:</p>
<div id="attachment_1572" style="width: 815px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-api-pagination-settings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1572" class="size-full wp-image-1572" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-api-pagination-settings.png" alt="Configure BigQuery API Pagination on SSIS JSON Source" width="805" height="576" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-api-pagination-settings.png 805w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-api-pagination-settings-300x215.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-api-pagination-settings-768x550.png 768w" sizes="(max-width: 805px) 100vw, 805px" /></a><p id="caption-attachment-1572" class="wp-caption-text">Configure BigQuery API Pagination on SSIS JSON Source</p></div>
<h4>Configure Array Transformation</h4>
<p>Now the last thing we have to configure is special 2-dimensional JSON array format used by BigQuery API:</p>
<ol>
<li>On the JSON Source UI go to 2D Array Transformation tab.</li>
<li>Enter the following settings:
<ol>
<li>For Transformation Type select <strong>Transform complex 2-dimensional array</strong>.</li>
<li>For Column Name filter enter <strong>$.schema.fields[*].name</strong>.</li>
<li>For Row Values Filter enter <strong>$.f[*].v</strong>.</li>
</ol>
</li>
</ol>
<div id="attachment_1575" style="width: 819px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-filter-extract-2d-array-get-data-from-google-bigquery.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1575" class="size-full wp-image-1575" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-filter-extract-2d-array-get-data-from-google-bigquery.png" alt="JSON Array Transformation Options" width="809" height="317" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-filter-extract-2d-array-get-data-from-google-bigquery.png 809w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-filter-extract-2d-array-get-data-from-google-bigquery-300x118.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-filter-extract-2d-array-get-data-from-google-bigquery-768x301.png 768w" sizes="(max-width: 809px) 100vw, 809px" /></a><p id="caption-attachment-1575" class="wp-caption-text">JSON Array Transformation Options</p></div>
<h4>Preview Data and Save UI</h4>
<p>That&#8217;s it click Preview to see some data. If you entered sample JobID for your User::vJobID variable then you will see some data. In the next section we will see how to load Google BigQuery data into SQL Server. You can click Columns Tab to review Metadata.</p>
<p>Click OK to save UI and generate Metadata.</p>
<p>&nbsp;</p>
<h3>Configure Target &#8211; Load Google BigQuery data into SQL Server</h3>
<p>Now you can connect your JSON Source to any target such as ZS Trash Destination or a real database destination such as OLEDB Destination.</p>
<p>If you wish to dump data from Google BigQuery to a SQL Server table then just perform the following steps:</p>
<ol>
<li>Drag and drop OLEDB Destination from SSIS Toolbox. Rename it to something like SQL Server Table.</li>
<li>Double click on OLEDB Destination.</li>
<li>Click New to create a new connection &gt; Configure connection &gt; Click OK.</li>
<li>Click on New to create a new table &gt; Rename default table name &gt; Click OK.</li>
<li>Click on Mappings tab and click OK to save UI with default mappings.</li>
</ol>
<div id="attachment_1580" style="width: 918px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-load-data-google-bigquery-to-sqlserver-table-json-connector.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1580" class="size-full wp-image-1580" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-load-data-google-bigquery-to-sqlserver-table-json-connector.png" alt="Configure SSIS OLEDB Destination - Google BigQuery to SQL Server Import" width="908" height="558" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-load-data-google-bigquery-to-sqlserver-table-json-connector.png 908w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-load-data-google-bigquery-to-sqlserver-table-json-connector-300x184.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-load-data-google-bigquery-to-sqlserver-table-json-connector-768x472.png 768w" sizes="(max-width: 908px) 100vw, 908px" /></a><p id="caption-attachment-1580" class="wp-caption-text">Configure SSIS OLEDB Destination &#8211; Google BigQuery to SQL Server Import</p></div>
<h3>Execute Package &#8211; Loading BigQuery data into SQL Server</h3>
<div id="attachment_1578" style="width: 596px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-package-execute-rest-api-loading-data-from-bigquery-to-sqlserver.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1578" class="size-full wp-image-1578" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-package-execute-rest-api-loading-data-from-bigquery-to-sqlserver.png" alt="SSIS Package Execution - Loading Google BigQuery Data into SQL Server" width="586" height="296" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-package-execute-rest-api-loading-data-from-bigquery-to-sqlserver.png 586w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-package-execute-rest-api-loading-data-from-bigquery-to-sqlserver-300x152.png 300w" sizes="(max-width: 586px) 100vw, 586px" /></a><p id="caption-attachment-1578" class="wp-caption-text">SSIS Package Execution &#8211;<br />Loading Google BigQuery Data into SQL Server</p></div>
<h2>Create / Delete Google BigQuery Dataset using API call</h2>
<p>As we mentioned before, you need dataset before you can create a table. Most common way to create dataset is via User Interface but what if you like to automate from your SSIS Package or other workflow? Here is how you can create or delete. Basically you can use REST API Task to send CREATE or DROP command for Dataset object</p>
<h3><strong>Create Google Dataset</strong></h3>
<p>To create dataset configure REST API Task using below settings (We will <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insert" target="_blank" rel="noopener">call this API</a>)</p>
<ol>
<li>Drag REST API Task from toolbox<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>Select URL from Connection mode and select connection as <strong>OAuth connection</strong> (Created in previous section)</li>
<li>Enter below URL (assuming you stored your ProjectID in a variable called ProjectId<br />
<pre class="crayon-plain-tag">https://bigquery.googleapis.com/bigquery/v2/projects/{{User::ProjectId}}/datasets</pre>
</li>
<li>Request Method as <strong>POST</strong></li>
<li>Enter Request Body as below (change YOUR_DATASET_NAME &#8211; e.g. TestDataset )<br />
<pre class="crayon-plain-tag">{"datasetReference": { "datasetId": "YOUR_DATASET_NAME", "projectId": "{{User::ProjectId}}"} }</pre>
</li>
<li>Select Request Content Type as <strong>application/json</strong> from the dropdown</li>
<li>(Optional) &#8211; If you want to implement Continue if Dataset already exists then you can go to Error Handling Tab (See next section for screenshot) and check <strong>Continue On Error Code</strong> option and set <strong>409 status code</strong></li>
<li>That&#8217;s it. Click Test Request/Response see it works.</li>
</ol>
<h3>Delete Google BigQuery Dataset</h3>
<p>For deleing dataset you have to choose same steps as above except two things</p>
<ol>
<li>Request Method as <strong>DELETE</strong></li>
<li>Request Body as blank</li>
</ol>
<h2>Create / Delete Google BigQuery Table using API call</h2>
<p>Now let&#8217;s look at how to create /drop Table in Google BigQuery using API calls.</p>
<h3>Create Google BigQuery Table</h3>
<p>To send <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#:~:text=%20%20%201%20Open%20the%20BigQuery%20web,table%20appears%20in%20the%20resources%20pane.%20More%20" target="_blank" rel="noopener">CREATE TABLE  SQL statement (DDL)</a> we have to use same approach as we send normal SQL Query <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query" target="_blank" rel="noopener">using this API call</a>. So notice we used Standard SQL for this call by supplying  <strong>useLegacySql: false</strong> . DDL Statement must be all in one line</p><pre class="crayon-plain-tag">POST https://www.googleapis.com/bigquery/v2/projects/{{User::ProjectId}}/queries

Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
 "query": "CREATE TABLE TestDataset.Table1 (RecordID INT64,CustomerID STRING,CustomerName STRING);",
 "useLegacySql": false,
 "timeoutMs": 100000 
}</pre><p>
To create dataset configure REST API Task using below settings</p>
<ol>
<li>Drag REST API Task from toolbox<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>Select URL from Connection mode and select connection as <strong>OAuth connection</strong> (Created in previous section)</li>
<li>Enter below URL (assuming you stored your ProjectID in a variable called ProjectId<br />
<pre class="crayon-plain-tag">https://bigquery.googleapis.com/bigquery/v2/projects/{{User::ProjectId}}/queries</pre>
</li>
<li>Request Method as <strong>POST</strong></li>
<li>Enter Request Body as below<br />
<pre class="crayon-plain-tag">{
 "query": "CREATE TABLE TestDataset.Table1 (RecordID INT64,CustomerID STRING,CustomerName STRING);",
 "useLegacySql": false,
 "timeoutMs": 100000
}</pre>
</li>
<li>Select Request Content Type as <strong>application/json</strong> from the dropdown</li>
<li>(Optional) &#8211; If you want to implement Continue if Table exists then you can go to enable Error Handling Tab and check <strong>Continue On Error Code</strong> option and set <strong>409 status code</strong></li>
<li>That&#8217;s it. Click Test Request/Response see it works.</li>
</ol>
<div id="attachment_8986" style="width: 1008px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-create-bigquery-table-rest-api-call-skip-if-exists.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8986" class="size-full wp-image-8986" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-create-bigquery-table-rest-api-call-skip-if-exists.png" alt="Create Google BigQuery Table - API Call (Continue On Error Setting - Skip CREATE if Table / Dataset Already Exists)" width="998" height="692" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-create-bigquery-table-rest-api-call-skip-if-exists.png 998w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-create-bigquery-table-rest-api-call-skip-if-exists-300x208.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-create-bigquery-table-rest-api-call-skip-if-exists-768x533.png 768w" sizes="(max-width: 998px) 100vw, 998px" /></a><p id="caption-attachment-8986" class="wp-caption-text">Create Google BigQuery Table &#8211; API Call (Continue On Error Setting &#8211; Skip CREATE if Table / Dataset Already Exists)</p></div>
<h3>Delete Google BigQuery Table</h3>
<p>For deleing table you have to choose same steps as above except two things</p>
<ol>
<li>Request Method as <strong>DELETE</strong></li>
<li>Request Body as blank</li>
</ol>
<h2>Write data to Google BigQuery using SSIS &#8211; 1 Million row insert test (FAST)</h2>
<p>Now let&#8217;s look at how easy it is to import data into Google BigQuery using SSIS. We will use the same OAuth connection we created before. To learn more about inserting data into BigQuery check <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll"><i>tabledata/insertAll </i>method documentation</a>.</p>
<h3>Make sure billing is enabled</h3>
<p>Make sure that billing is enabled for your Google Cloud project. <a href="https://cloud.google.com/billing/docs/how-to/modify-project" target="_blank" rel="noopener">Learn how to confirm billing is enabled for your project</a>.</p>
<p>Streaming is not available via the <a href="https://cloud.google.com/bigquery/pricing#free-tier">free tier</a>. If you attempt to use streaming without enabling billing, you receive the following error: <code translate="no" dir="ltr">BigQuery: Streaming insert is not allowed in the free tier.</code></p>
<p>As long as your API calls fall under Free Tier  limit you wont be charged but you still need to enable billing if you wish to call Streaming insertAll API call (Write  demo).</p>
<h3>Configure OAuth Connection / Permissions</h3>
<p>If you want to perform data insert operation in BigQuery using API calls then include the following scopes in your OAuth Connection Manager and generate a token (see our first section of this article &#8211; We already included scopes for Write operation but incase you didnt do then regenerate token with below scopes):</p><pre class="crayon-plain-tag">https://www.googleapis.com/auth/bigquery
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/bigquery.insertdata</pre><p>
<h3>Create BigQuery Dataset (From UI)</h3>
<p>For this demo first create a test dataset and one table under it like shown below (<em>billing must be enabled on your Google API Project</em>). To do that go to <a href="https://bigquery.cloud.google.com/welcome" target="_blank" rel="noopener">https://bigquery.cloud.google.com/welcome</a> and configure them:</p>
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE:</strong> BigQuery now provides a <a href="https://cloud.google.com/bigquery/docs/sandbox">sandbox</a> if you do not want to provide a credit card or enable billing for your project. The steps in this topic work for a project whether or not your project has billing enabled. If you optionally want to enable billing, see <a href="https://cloud.google.com/billing/docs/how-to/modify-project" target="_blank" rel="noopener">Learn how to enable billing</a>. There are some restriction on Sandbox mode (Write API calls will fail &#8211; Check Common Errors section later this article)</div></div>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-console-create-dataset-table-defination.png"><img loading="lazy" decoding="async" class="size-full wp-image-2354" src="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-console-create-dataset-table-defination.png" alt="Create sample dataset and table for Google BigQuery Load" width="715" height="599" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-console-create-dataset-table-defination.png 715w, https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-console-create-dataset-table-defination-300x251.png 300w" sizes="(max-width: 715px) 100vw, 715px" /></a></p>
<h3>Insert data into BigQuery using API call</h3>
<p>And here is a REST API example to insert data into a BigQuery Table:</p>
<p><strong>Request URL:</strong></p><pre class="crayon-plain-tag">https://www.googleapis.com/bigquery/v2/projects/MY_PROJECT_ID/datasets/MY_DATASET_ID/tables/MY_TABLE_ID/insertAll</pre><p>
<strong>Request Headers:</strong></p><pre class="crayon-plain-tag">Authorization: Bearer ya29.Gl0cBxxxxxxxxxxxxxxxxxxuEIhJIEnxE6GsQPHI
Content-Type: application/json</pre><p>
<strong>Request Body:</strong></p><pre class="crayon-plain-tag">{
  "kind": "bigquery#tableDataInsertAllRequest",
  "rows": [
     {"json": {"RowId": 1,"CustomerName": "AAA"} }, 
     {"json": {"RowId": 2,"CustomerName": "BBB"} }
   ]
}</pre><p>
<h3></h3>
<p>Here is our data flow setup to achive very high throughput for Google BigQuery Data Load. We will show you how to insert one million rows in Google BigQuery in less than a minute based on below setup. We will use Multi Threading option and New Compression Option (Added in v3.1.4)</p>
<ol>
<li>Dummy Data Source &#8211; Generate sample records</li>
<li>JSON Generator Transform &#8211; Generates JSON documents to send as POST request for above /insertAll API call.</li>
<li>Web API destination  &#8211; Call /insertAll API call to submit our data to BigQuery</li>
<li><strong>(Optional)</strong> JSON Parser Transform &#8211; Parse Error Message for any response</li>
<li><strong>(Optional)</strong> Trash Destination &#8211; Save any errors to text file for review</li>
</ol>
<div id="attachment_8973" style="width: 910px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-fast-data-load-ssis-multi-threads-insert-compression-on.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8973" class="size-full wp-image-8973" src="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-fast-data-load-ssis-multi-threads-insert-compression-on.png" alt="Google BigQuery Data Load Demo in SSIS - 1 Million Rows Insert with Multi Threads and Compression ON (Fast Upload)" width="900" height="724" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-fast-data-load-ssis-multi-threads-insert-compression-on.png 900w, https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-fast-data-load-ssis-multi-threads-insert-compression-on-300x241.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/google-bigquery-fast-data-load-ssis-multi-threads-insert-compression-on-768x618.png 768w" sizes="(max-width: 900px) 100vw, 900px" /></a><p id="caption-attachment-8973" class="wp-caption-text">Google BigQuery Data Load Demo in SSIS &#8211; 1 Million Rows Insert with Multi Threads and Compression ON (Fast Upload)</p></div>
<p>&nbsp;</p>
<h3>Configure SSIS JSON Generator &#8211; Generate JSON for BigQuery Table Insert</h3>
<p>Now let&#8217;s see how to build an HTTP request with JSON body and send it to BigQuery:</p>
<ol style="margin-left: 0;">
<li>Drag Data Flow Task and double click on it.<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>Drag and configure your Source (for this demo we use Dummy Data Source with Customer Template). See previous section for configuration of Dummy Data Source.<br />
<img decoding="async" class="figureimage" title="SSIS DummyData Source - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/dummy-data-Source/ssis-dummy-data-source-adapter-drag.png" alt="SSIS DummyData Source - Drag and Drop" /></li>
<li>Drag and drop <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">ZS JSON Generator Transform</a> to produce JSON from a database or file records. If your source is already sending a valid JSON then you can skip this step (e.g. SQL query is<br />
returning JSON). You can also read raw JSON from a very large file (new-line separated JSON) using <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source with Output as Raw Data</a> option checked.<img decoding="async" class="figureimage" title="SSIS JSON Generator - Drag and Drop" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/json-generator-transform/ssis-json-generator-transform-drag-2.png" alt="SSIS JSON Generator - Drag and Drop" /></li>
<li>Connect Source to JSON Generator. Double click JSON Generator Transform to start configuring it like below.</li>
<li>Select Output Mode as <strong>Single Dataset Array</strong> and enter Batch Size <strong>10000</strong> (This is Max limit allowed by Google BigQuery API <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll" target="_blank" rel="noopener">insertAll</a>)</li>
<li>First <strong>right click</strong> on Mappings node and select <strong>Add Static Element</strong>
<div id="attachment_8975" style="width: 862px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-insert-request-batch-json-generate.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8975" class="size-full wp-image-8975" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-insert-request-batch-json-generate.png" alt="Generate JSON for Google BigQuery InsertAll API request - Batch 10000 rows in a single API call" width="852" height="391" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-insert-request-batch-json-generate.png 852w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-insert-request-batch-json-generate-300x138.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-insert-request-batch-json-generate-768x352.png 768w" sizes="(max-width: 852px) 100vw, 852px" /></a><p id="caption-attachment-8975" class="wp-caption-text">Generate JSON for Google BigQuery InsertAll API request &#8211; Batch 10000 rows in a single API call</p></div></li>
<li>Enter Name as <strong>kind</strong> and value as <strong><strong>bigquery#tableDataInsertAllRequest<br />
</strong></strong></p>
<div id="attachment_8976" style="width: 538px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-static-value.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8976" class="size-full wp-image-8976" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-static-value.png" alt="JSON Generator - Add Static Element" width="528" height="373" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-static-value.png 528w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-static-value-300x212.png 300w" sizes="(max-width: 528px) 100vw, 528px" /></a><p id="caption-attachment-8976" class="wp-caption-text">JSON Generator &#8211; Add Static Element</p></div></li>
<li>Now right click on Mappings node and select <strong>Add Document Array</strong> option
<div id="attachment_8978" style="width: 464px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array-option.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8978" class="wp-image-8978 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array-option.png" alt="JSON Generator - Add Document Array" width="454" height="349" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array-option.png 454w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array-option-300x231.png 300w" sizes="(max-width: 454px) 100vw, 454px" /></a><p id="caption-attachment-8978" class="wp-caption-text">JSON Generator &#8211; Add Document Array</p></div></li>
<li>Enter <strong>rows</strong> as array title and click OK
<div id="attachment_8979" style="width: 470px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8979" class="size-full wp-image-8979" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array.png" alt="JSON Generator - Name array" width="460" height="313" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array.png 460w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-document-array-300x204.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></a><p id="caption-attachment-8979" class="wp-caption-text">JSON Generator &#8211; Name array</p></div></li>
<li>Select newly added array node and right click &gt; Add <strong>unbound nested element</strong>  enter Output alias as <strong>json </strong>and click OK.
<div id="attachment_8980" style="width: 475px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-unbound-element.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8980" class="size-full wp-image-8980" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-unbound-element.png" alt="JSON Generator - Add unbound nested element" width="465" height="471" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-unbound-element.png 465w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-unbound-element-296x300.png 296w" sizes="(max-width: 465px) 100vw, 465px" /></a><p id="caption-attachment-8980" class="wp-caption-text">JSON Generator &#8211; Add unbound nested element</p></div></li>
<li>Select <strong>json</strong> node and right click &gt; Select <strong>Add Elements below</strong> this node and select multiple columns you like to send to BigQuery. Click OK to save.
<div id="attachment_8981" style="width: 467px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-multiple-elements.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8981" class="size-full wp-image-8981" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-multiple-elements.png" alt="JSON Generator - Add Multiple Elements" width="457" height="529" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-multiple-elements.png 457w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-json-generator-add-multiple-elements-259x300.png 259w" sizes="(max-width: 457px) 100vw, 457px" /></a><p id="caption-attachment-8981" class="wp-caption-text">JSON Generator &#8211; Add Multiple Elements</p></div></li>
<li>Now let&#8217;s preview our JSON (Copy preview JSON to try in the next step &#8211; Web API destination)<div class="su-note"  style="border-color:#e5da9d;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:#fff4b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Table name and column names are case-sensitive so make sure your JSON attribute matches exact same way. </div></div>Here is the finished JSON Structure for next Step
<div id="attachment_8982" style="width: 857px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/create-google-bigquery-request-json-insertall-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8982" class="size-full wp-image-8982" src="https://zappysys.com/blog/wp-content/uploads/2017/07/create-google-bigquery-request-json-insertall-api.png" alt="Sample JSON Request body for Google BigQuery insertAll API request" width="847" height="671" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/create-google-bigquery-request-json-insertall-api.png 847w, https://zappysys.com/blog/wp-content/uploads/2017/07/create-google-bigquery-request-json-insertall-api-300x238.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/create-google-bigquery-request-json-insertall-api-768x608.png 768w" sizes="(max-width: 847px) 100vw, 847px" /></a><p id="caption-attachment-8982" class="wp-caption-text">Sample JSON Request body for Google BigQuery insertAll API request</p></div></li>
<li>Click OK to save UI.</li>
</ol>
<h3>Configure SSIS Web API destination &#8211; Insert data into BigQuery Table</h3>
<p>Once you have Input JSON prepared,  now let&#8217;s configure destination for BigQuery.</p>
<ol style="margin-left: 0;">
<li>Drag and drop <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">ZS Web API Destination</a>.</li>
<li>Connect your JSON Generator Transform to Web API destination.</li>
<li>Configure general properties:
<div id="attachment_2349" style="width: 869px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-load-using-web-api-destination.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2349" class="size-full wp-image-2349" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-load-using-web-api-destination.png" alt="SSIS Web API Destination - Configure for BigQuery Data load" width="859" height="583" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-load-using-web-api-destination.png 859w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-load-using-web-api-destination-300x204.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-load-using-web-api-destination-768x521.png 768w" sizes="(max-width: 859px) 100vw, 859px" /></a><p id="caption-attachment-2349" class="wp-caption-text">SSIS Web API Destination &#8211;<br />Configure for BigQuery Data load</p></div></li>
<li>Make sure to enter URL in this format:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/bigquery/v2/projects/MY_PROJECT_ID/datasets/MY_DATASET_ID/tables/MY_TABLE_ID/insertAll</pre>
Make sure to replace 3 parts in above URL (MY_PROJECT_ID, MY_DATASET_ID, MY_TABLE_ID) with actual values from your Google Project and BigQuery dataset/table configuration.</li>
<li>Now you can enable Compression and Multiple Threads for higher throughput as below.<br />
<strong>NOTE:</strong> Compression Property was added in v3.1.4 so you may not see it if you have older version.</p>
<div id="attachment_8983" style="width: 1042px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8983" class="size-full wp-image-8983" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads.png" alt="Google BigQuery Data Loading Performance Optimization Options - Enable Multiple Threads and Compression Options" width="1032" height="347" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads.png 1032w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads-300x101.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads-768x258.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-rest-api-post-data-request-performance-optimization-gzip-compression-multi-threads-1024x344.png 1024w" sizes="(max-width: 1032px) 100vw, 1032px" /></a><p id="caption-attachment-8983" class="wp-caption-text">Google BigQuery Data Loading Performance Optimization Options &#8211; Enable Multiple Threads and Compression Options</p></div></li>
<li>If you want to try test insert request from UI without running full package then go back to first tab and edit Body (Use Sample JSON generated by previous JSON Transform &#8211; You can grab from JSON Preview Panel on Generator Transform).Click Test Request / Response and confirm Success as below. You can go back to your BigQuery Portal and check one row is inserted after our test click. If everything looking good then run full package to insert all records.Sample JSON for Body:<br />
<pre class="crayon-plain-tag">{
  "kind": "bigquery#tableDataInsertAllRequest",
  "rows": [
     {"json": {"RowId": 1,"CustomerName": "AAA"} }, 
     {"json": {"RowId": 2,"CustomerName": "BBB"} }
   ]
}</pre>
<div id="attachment_4919" style="width: 910px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-test-insert-dataset-record-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4919" class="size-full wp-image-4919" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-test-insert-dataset-record-api.png" alt="Test Google BigQuery Table Insert - SSIS Web API Destination UI" width="900" height="730" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-test-insert-dataset-record-api.png 900w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-test-insert-dataset-record-api-300x243.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-google-bigquery-test-insert-dataset-record-api-768x623.png 768w" sizes="(max-width: 900px) 100vw, 900px" /></a><p id="caption-attachment-4919" class="wp-caption-text">Test Google BigQuery Table Insert &#8211; SSIS Web API Destination UI</p></div></li>
<li>Hit OK to save UI.</li>
<li>Run the package and verify data in Google BigQuery Console:
<div id="attachment_2351" style="width: 1206px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2351" class="size-full wp-image-2351" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example.png" alt="Loading data into Google BigQuery using SSIS" width="1196" height="625" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example.png 1196w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example-300x157.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example-768x401.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-example-1024x535.png 1024w" sizes="(max-width: 1196px) 100vw, 1196px" /></a><p id="caption-attachment-2351" class="wp-caption-text">Loading data into Google BigQuery using SSIS</p></div></li>
</ol>
<h2></h2>
<h2>Error Handling for BigQuery Data Load (Bulk Insert API Calls)</h2>
<p>There will be a time when some records you insert may not go well in Google BigQuery. In such case you can read output from Web API destination and parse further with JSON Parser Transform. Check for certain values in the output. You must use JSON Parser after Web API destination (Connect <strong>Blue Arrow</strong> from Web API destination &#8211; Since its Soft Error it won&#8217;t redirect in Red Arrow ).</p>
<p>For example here is the sample JSON in POST Body for testing which produces error due to bad column name. When bad row found in batch all records will be rejected. Notice that error returns index of record in batch so you can identify which row went bad. It also returns column name in location attribute.</p>
<p><strong>NOTE: Bad column name in 2nd record</strong></p>
<p><strong>Test Body (Bad):</strong></p><pre class="crayon-plain-tag">{
  "kind": "bigquery#tableDataInsertAllRequest",
  "rows": [
     {"json": {"RecordID": 1,"CustomerID": "X1"} }, 
     {"json": {"Bad_Column": 2,"CustomerID": "X2"} }
     {"json": {"RecordID": 3,"CustomerID": "X3"} }, 
   ]
}</pre><p>
&nbsp;</p>
<p><strong>Response (For Bad Input):</strong></p><pre class="crayon-plain-tag">{
  "kind": "bigquery#tableDataInsertAllResponse",
  "insertErrors": [
    {
      "index": 1,
      "errors": [
        {
          "reason": "invalid",
          "location": "bad_column",
          "debugInfo": "",
          "message": "no such field."
        }
      ]
    },
    {
      "index": 0,
      "errors": [
        {
          "reason": "stopped",
          "location": "",
          "debugInfo": "",
          "message": ""
        }
      ]
    },
    {
      "index": 2,
      "errors": [
        {
          "reason": "stopped",
          "location": "",
          "debugInfo": "",
          "message": ""
        }
      ]
    }
  ]
}</pre><p>
&nbsp;</p>
<p>To configure error detection perform following steps.</p>
<ol>
<li>Drag and drop <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">ZS JSON Parser Transform</a> after Web API destination</li>
<li>Click on Web API destination. Connect Blue arrow  to JSON Parser Transform</li>
<li>Configure JSON Parser Transform like below</li>
<li>Connect JSON Parser TRansform to some Destination to save error information (e.g. SQL Table or Trans destination)</li>
</ol>
<div id="attachment_4920" style="width: 1111px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4920" class="size-full wp-image-4920" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser.png" alt="Handling BigQuery Insert Errors in SSIS " width="1101" height="739" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser.png 1101w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser-300x201.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser-768x515.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser-1024x687.png 1024w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-handle-bigquery-insert-errors-json-parser-272x182.png 272w" sizes="(max-width: 1101px) 100vw, 1101px" /></a><p id="caption-attachment-4920" class="wp-caption-text">Handling BigQuery Insert Errors in SSIS</p></div>
<h2>Other Common Errors in BigQuery API calls</h2>
<p>In this section we will talk about many common API errors in BigQuery.</p>
<h3>Error: The project XXXXXXX has not enabled BigQuery</h3>
<p>Sometimes you might get below error. To fix this error make sure you go to your Project and <a href="https://console.cloud.google.com/apis/library/bigquery.googleapis.com" target="_blank" rel="noopener">Enable BigQuery API</a></p><pre class="crayon-plain-tag">Status Code: BadRequest

Response Body: {
  "error": {
    "code": 400,
    "message": "The project bigquerytest-281915 has not enabled BigQuery.",
    "errors": [
      {
        "message": "The project bigquerytest-281915 has not enabled BigQuery.",
        "domain": "global",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}</pre><p>
<h3>Error: 404 &#8211; Not Found: Table / Job xxxxxx</h3>
<ul>
<li>Make sure you are setting GET request and not POST.</li>
<li>Also make sure your jobId is valid because it expires after 24 hours.</li>
<li>Make sure project-id supplied in URL is valid ID  (DO NOT Specify Alias, use internal ID for project)</li>
<li>
<div>Make sure you supplied location parameter if your outside EU / US region. Reading data using <a href="https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults" target="_blank" rel="noopener">this API call</a> might fail if you failed to supply <strong>location</strong> in URL</div>
</li>
</ul>
</p><pre class="crayon-plain-tag">{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found: Table xxxxxx"
   }
  ],
  "code": 404,
  "message": "Not Found: Table xxxxxxx
 }
}</pre><p>
&nbsp;</p>
<h3>Error: 403 &#8211; Access Denied: BigQuery BigQuery: Streaming insert is not allowed in the free tier</h3>
<p>If you trying call certain APIs on sandbox mode or free tier then you might get below error. To overcome this error <a href="https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project" target="_blank" rel="noopener">enable billing on google bigquery</a>. As long as your API calls fall under Free Tier  limit you wont be charged but you still need to enable billing if you wish to call Streaming insertAll API call.</p><pre class="crayon-plain-tag">Response Url: https://www.googleapis.com/bigquery/v2/projects/bigquerytest-281915/datasets/TestDataset/tables/Table1/insertAll

Status Code: Forbidden

Response Body: {
  "error": {
    "code": 403,
    "message": "Access Denied: BigQuery BigQuery: Streaming insert is not allowed in the free tier",
    "errors": [
      {
        "message": "Access Denied: BigQuery BigQuery: Streaming insert is not allowed in the free tier",
        "domain": "global",
        "reason": "accessDenied"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}</pre><p>
&nbsp;</p>
<p>&nbsp;</p>
<h2>Debugging Web API Requests</h2>
<p>If you need to debug actual requests made to Google server then you can use a tool like <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/" target="_blank" rel="noopener">Fiddler</a>. It&#8217;s a very handy tool to troubleshoot JSON format issues. It will allow to see how a request is made to a server.</p>
<div id="attachment_2352" style="width: 1076px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2352" class="size-full wp-image-2352" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler.png" alt="Using Fiddler to debug Google BigQuery API requests in SSIS" width="1066" height="719" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler.png 1066w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler-300x202.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler-768x518.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler-1024x691.png 1024w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-bigquery-data-import-debug-api-request-using-fiddler-272x182.png 272w" sizes="(max-width: 1066px) 100vw, 1066px" /></a><p id="caption-attachment-2352" class="wp-caption-text">Using Fiddler to debug Google BigQuery API requests in SSIS</p></div>
<h2>Common Errors</h2>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2>Deployment to Production</h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<h2>Download Sample Package</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/Google_BigQuery_API_Read_Write_Create_Delete_Sample_SSIS2019_2017_2012.zip">Click Here to Download SSIS Sample Package &#8211; Google BigQuery API Read Write Create Delete (SSIS 2019, 2017, 2012)</a></p>
<p>&nbsp;</p>
<h2>Conclusion. What&#8217;s next?</h2>
<p>In this article we have learned how to load data from Google BigQuery into SQL Server using SSIS (drag and drop approach without coding). We used <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS JSON / REST API Connector</a> to extract data from Google BigQuery REST API using OAuth. JSON Source Connector makes it super simple to parse complex/large JSON files or any Web API response into rows and columns so you can load data into a database, e.g. SQL Server database. <a href="//zappysys.com/products/ssis-powerpack/">Download SSIS PowerPack</a> to try many other automation scenarios that were not discussed in this article.</p>
<p><strong>Keywords:</strong></p>
<p>Google BigQuery Integration with SQL Server | How to extract data from google bigquery in SSIS? | How to read data from Google BigQuery API? | Loading BigQuery Data into SQL Server. | BigQuery to SQL Server | SSIS Google Big Query Integration | SSIS Google BigQuery Import  JSON File | SSIS Google BigQuery Export data</p>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/get-data-google-bigquery-using-ssis/">How to read / write data in Google BigQuery using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>3 ways to get Google Analytics unsampled data in SSIS</title>
		<link>https://zappysys.com/blog/3-ways-get-unsampled-data-ssis-google-analytics-source/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Wed, 26 Apr 2017 17:20:45 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[SSIS Google Analytics Source]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[ssis google analytics source]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1129</guid>

					<description><![CDATA[<p>Introduction In our previous post, we saw how to get data from Google Analytics using SSIS. Once you get going with the drag and drop SSIS Google Analytics Connector, you may bump up to one interesting challenge. If your request includes sessions above a certain threshold, Google may start sampling your data to provide an average for [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/3-ways-get-unsampled-data-ssis-google-analytics-source/">3 ways to get Google Analytics unsampled data 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 <a href="https://zappysys.com/blog/get-data-from-google-analytics-in-ssis-using-rest-api-call/" target="_blank" rel="noopener">how to get data from Google Analytics using SSIS</a>. Once you get going with the <a href="//zappysys.com/products/ssis-powerpack/ssis-google-analytics-source-connector/" target="_blank" rel="noopener">drag and drop SSIS Google Analytics Connector</a>, you may bump up to one interesting challenge. If your request includes sessions above a certain threshold, Google may start sampling your data to provide an average for many Metrics. So, how do you make sure your request includes all sessions in the calculation? The following sections will describe a few ways to achieve this.</p>
<h2>Google Analytics Data Sampling Tips</h2>
<p>There is no way to guarantee 100% Unsampled data in the Standard Google Analytics API call due to restrictions imposed by Google. However, there are a few workarounds that may help you achieve a very high Data Sampling rate.</p>
<p><span style="box-sizing: border-box; margin: 0px; padding: 0px;">The most common solution is that if you set the Sampling option to HIGHER_PRECISION, then Google may honor your request up to a certain threshold, but as the dataset grows (e.g., if you select a larger date range), Google may sample your data even though you set <strong>HIGHER_PRECISION</strong>.</span></p>
<div id="attachment_11615" style="width: 648px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/04/Extract-data-from-Google-Analytics-in-SSIS-Use-Sample-Size-option-to-get-Unsampled-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11615" class="size-full wp-image-11615" src="https://zappysys.com/blog/wp-content/uploads/2017/04/Extract-data-from-Google-Analytics-in-SSIS-Use-Sample-Size-option-to-get-Unsampled-data.png" alt="" width="638" height="670" srcset="https://zappysys.com/blog/wp-content/uploads/2017/04/Extract-data-from-Google-Analytics-in-SSIS-Use-Sample-Size-option-to-get-Unsampled-data.png 638w, https://zappysys.com/blog/wp-content/uploads/2017/04/Extract-data-from-Google-Analytics-in-SSIS-Use-Sample-Size-option-to-get-Unsampled-data-286x300.png 286w" sizes="(max-width: 638px) 100vw, 638px" /></a><p id="caption-attachment-11615" class="wp-caption-text">Extract data from Google Analytics in SSIS: Use the Sample Size option to get Unsampled data.</p></div>
<h2>Other ways to get unsampled data from the Google Analytics API</h2>
<p>Now, let&#8217;s look at a few other ways if the previous approach doesn&#8217;t work.</p>
<ol>
<li>Narrow down your Date range&#8230; e.g., Process day by day rather than a full extract. If day by day is also sampling, they try Hour-by-Hour.</li>
<li>Use the Google API to generate and download Unsampled data (We don&#8217;t have an article on this, but see the reference below).</li>
<li>Use a Google Analytics 360 Premium Account with the unsampled report feature. You can get this via the Web Interface or call the API to automate the extraction. <a href="https://support.google.com/analytics/answer/2601061?hl=en" target="_blank" rel="noopener">https://support.google.com/analytics/answer/2601061?hl=en</a></li>
</ol>
<p><a href="https://developers.google.com/analytics/devguides/config/mgmt/v3/unsampled-reports" target="_blank" rel="noopener">https://developers.google.com/analytics/devguides/config/mgmt/v3/unsampled-reports</a><br />
<a href="https://support.google.com/analytics/answer/2637192?hl=en&amp;visit_id=1-636288218914624195-2113255108&amp;rd=1" target="_blank" rel="noopener">https://support.google.com/analytics/answer/2637192?hl=en&amp;visit_id=1-636288218914624195-2113255108&amp;rd=1</a></p>
<p><strong>Downloading Unsampled report using Google Analytics 360 API &#8211; ZappySys REST API Task</strong></p>
<p>If you are a Google Analytics 360 user and wish to use the API to generate a file and download it in SSIS, refer to the following article. It shows how to call the Google API. It&#8217;s not about the Analytics API, but you will get a high-level idea.</p>
<p><a href="https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/">https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/</a></p>
<p>The post <a href="https://zappysys.com/blog/3-ways-get-unsampled-data-ssis-google-analytics-source/">3 ways to get Google Analytics unsampled data in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to call Google DFP API with SSIS &#8211; DoubleClick</title>
		<link>https://zappysys.com/blog/calling-google-dfp-api-with-ssis-doubleclick-soap-api/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 14 Feb 2017 19:28:31 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[AdSense]]></category>
		<category><![CDATA[AdWords]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[DFP]]></category>
		<category><![CDATA[doubleclick]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis rest api task]]></category>
		<category><![CDATA[ssis xml source]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1000</guid>

					<description><![CDATA[<p>Introduction Google DoubleClick is one of the most popular platforms for Advertisers. Many times you have need for custom integration or Automation for many operations. In this article we will learn how to Call Google DFP API (i.e. DoubleClick for Publishers) without coding using SSIS (Microsoft SQL Server Integration Services). In our previous article we [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/calling-google-dfp-api-with-ssis-doubleclick-soap-api/">How to call Google DFP API with SSIS &#8211; DoubleClick</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="//zappysys.com/blog/wp-content/uploads/2017/02/google-doubleclick-dfp-api-integration.png"><img loading="lazy" decoding="async" class=" wp-image-1634 alignleft" src="//zappysys.com/blog/wp-content/uploads/2017/02/google-doubleclick-dfp-api-integration.png" alt="" width="198" height="198" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/google-doubleclick-dfp-api-integration.png 500w, https://zappysys.com/blog/wp-content/uploads/2017/02/google-doubleclick-dfp-api-integration-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/02/google-doubleclick-dfp-api-integration-300x300.png 300w" sizes="(max-width: 198px) 100vw, 198px" /></a>Google DoubleClick is one of the most popular platforms for Advertisers. Many times you have need for custom integration or Automation for many operations. In this article we will learn how to Call Google DFP API (i.e. DoubleClick for Publishers) without coding using SSIS (Microsoft SQL Server Integration Services). In our previous article we discussed how to Integrate <a href="https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/" target="_blank" rel="noopener">Google AdWords API using SSIS (Click here)</a>.</p>
<p>If you are new to SSIS then no worry there are plenty of <a href="http://www.bing.com/search?q=ssis+tutorials&amp;src=IE-TopResult&amp;FORM=IE11TR&amp;conversationid=" target="_blank" rel="noopener">tutorials for ssis</a></p>
<p>To achieve Custom integration for DoubleClick (DFP) API we will use <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">SSIS XML Source</a>. XML Source is part of <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> which has 45+ connectors and Tasks.</p>
<p>&nbsp;</p>
<h2>Prerequisite</h2>
<p>Before you can finish tasks explained in this article you have to finish below steps. This article assumes you have basic knowledge of SSIS (SQL Server Integration Services)</p>
<ol>
<li>Make sure you SSIS designer installed. Sometimes its referred 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></li>
<li><a href="https://www.soapui.org/downloads/soapui.html" target="_blank" rel="noopener">Download SoapUI</a> (Its free third party tool to test SOAP API). SoapUI can help you to generate XML Request BODY easily from WSDL file provided by API Vendor. You can also test your service by supplying parameters.</li>
<li>Optional &#8211; 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>Download DFP API Example SSIS Package</h2>
<p><a href="//zappysys.com/blog/wp-content/uploads/2017/02/Google-DoubleClick-API-SSIS-DEMO.zip" target="_blank" rel="noopener">Click here to DFP API download Sample for SSIS</a> SSIS Package (SSIS 2012, 2014, 2016)</p>
<p>Screenshot of Sample Package:</p>
<div id="attachment_1059" style="width: 977px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-example-call-google-dfp-api-get-data-from-doubleclick.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1059" class="size-full wp-image-1059" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-example-call-google-dfp-api-get-data-from-doubleclick.png" alt="Example SSIS Package - Google DFP API Integration (Read / Write data in Google Double Click for Publisher) - No Coding required" width="967" height="650" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-example-call-google-dfp-api-get-data-from-doubleclick.png 967w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-example-call-google-dfp-api-get-data-from-doubleclick-300x202.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-example-call-google-dfp-api-get-data-from-doubleclick-272x182.png 272w" sizes="(max-width: 967px) 100vw, 967px" /></a><p id="caption-attachment-1059" class="wp-caption-text">Example SSIS Package &#8211; Google DFP API Integration (Read / Write data in Google Double Click for Publisher) &#8211; No Coding required</p></div>
<h2>Making your first DFP API Call using SSIS</h2>
<p>Once you install <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">PowerPack</a> you are ready to execute your very first Google DFP API Call.</p>
<p><strong>NOTE</strong>: If you don&#8217;t have any DFP network for test then see next section (Explains how to create test network for testing).</p>
<p>Lets look at how to call Google DFP API step-by-step.</p>
<ol>
<li>Create new SSIS Project and open package designer</li>
<li>Drag <a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">ZS REST API Task</a> from SSIS control flow toolbox and drop it on designer.<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;"><a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a> is useful when you want to call SOAP/REST API but not necessarily parse response into rows and columns. We will look at <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source</a> later in this article which can actually parse response into rows and columns (Useful to load Google DFP data into SQL Server or other RDBMS / flatfile )</div></div></li>
<li>Double click REST API Task to configure. Select Access mode to [Url from Connection]</li>
<li>Enter following URL in the URL Textbox<br />
<pre class="crayon-plain-tag">&nbsp;https://ads.google.com/apis/ads/publisher/v201702/NetworkService</pre>
</li>
<li>From the connection dialogbox select <strong>ZS-OAUTH</strong> to create new OAuth Connection for DFP API</li>
<li>On OAuth Connection dialogbox select <strong>Google</strong> from Provider dropdown. In this demo we will use Default OAuth App but you can <a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">register your own google OAuth app</a> if you wish to use Custom OAuth option from UI.</li>
<li>Enter following Scopes in the Scopes textbox (or select manually by clicking Select Scopes button). Scope is nothing but permission for API (In our case View/Manage DFP data and Read/Write Report Files to Cloud Storage).<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/dfp
https://www.googleapis.com/auth/devstorage.read_only
https://www.googleapis.com/auth/devstorage.write_only
https://www.googleapis.com/auth/cloud-platform.read-only
https://www.googleapis.com/auth/devstorage.full_control
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/devstorage.read_write</pre>
</li>
<li>If you are not going call <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService" target="_blank" rel="noopener">ReportService</a> API to generate Reports in CSV format then you will need only one scope<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/dfp</pre>
</li>
<li>Click Generate Token button. You will see browser popup for login and then Accept option to confirm permissions like below. Once you don&#8217;t it will populate tokens and prompt to save tokens to backup file. Secure token backup to safe place.
<div id="attachment_1034" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-2-connection-call-google-dfp-api-doubleclick-soap-webservice.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1034" class="wp-image-1034" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-2-connection-call-google-dfp-api-doubleclick-soap-webservice.png" alt="SSIS OAuth Connection - Connect to Google DFP API (DoubleClick SOAP Web Service)" width="600" height="491" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-2-connection-call-google-dfp-api-doubleclick-soap-webservice.png 816w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-2-connection-call-google-dfp-api-doubleclick-soap-webservice-300x246.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-1034" class="wp-caption-text">SSIS OAuth Connection &#8211; Connect to Google DFP API (DoubleClick SOAP Web Service)</p></div></li>
<li>Once done Click Test Connection and if its green then Click OK to save connection</li>
<li>Once you are back to REST API Task UI then select Method to <strong>POST</strong></li>
<li>Select Request Body <strong>Content Type</strong> to XML (i.e. text/xml)</li>
<li>Click edit button next to <strong>Request Body</strong> and enter following XML.<br />
<pre class="crayon-plain-tag">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
   &lt;soapenv:Header&gt;
      &lt;v20:RequestHeader/&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
      &lt;v20:getAllNetworks/&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre>
<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;">
<p>If you are wondering how did we get above XML fragment then read next section about using 3rd party tool called SoapUI. Also we have detail article for calling SOAP request. <a href="//zappysys.com/blog/calling-soap-web-service-in-ssis-xml-source/" target="_blank" rel="noopener">Check this article on how to use SoapUI (free 3rd party tool) to create SOAP request Bodyfrom WSDL</a>. DFP has many API endpoints for different actions (e.g. <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService" target="_blank" rel="noopener">NetworkService</a> , <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/InventoryService" target="_blank" rel="noopener">InventoryService</a> , &#8230;). For each service you have different Api URL and different WSDL. In the next section you can learn how to create correct SOAP Body (for POST) using <strong>SoapUI</strong> tool.</p>
<p>For example if you using DFP NetworkService API for version v201702 then your <strong>help page URL would be like this</strong><br />
<a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService" target="_blank" rel="noopener">https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService</a><br />
And on the same page you will see <strong>WSDL link below</strong><br />
<a href="https://adwords.google.com/api/adwords/mcm/v201609/ManagedCustomerService?wsdl" target="_blank" rel="noopener">https://adwords.google.com/api/adwords/mcm/v201609/ManagedCustomerService?wsdl</a><br />
(Just download that WSDL XML and save to local disk then use with SoapUI to generate XML body to submit for any DFP API call.)</p>
</div></div></li>
<li>Once you done with above steps, your Task Configuration will look like below.
<div id="attachment_1035" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-task-call-dfp-google-doubleclick-api-getAllNetworks.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1035" class="wp-image-1035" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-task-call-dfp-google-doubleclick-api-getAllNetworks.png" alt="SSIS Rest API Task - Call Google DoubleClick API - Get all DFP Networks" width="600" height="522" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-task-call-dfp-google-doubleclick-api-getAllNetworks.png 805w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-task-call-dfp-google-doubleclick-api-getAllNetworks-300x261.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-1035" class="wp-caption-text">SSIS Rest API Task &#8211; Call Google DoubleClick API &#8211; Get all DFP Networks</p></div></li>
<li>Now click Test Request button. You will see Response popup with below content if its successful (Scroll at the bottom on response form and you will see XML data) .. see below<br />
<pre class="crayon-plain-tag">------------------------------------
Request
------------------------------------
POST https 1.1 ==&gt; /apis/ads/publisher/v201702/NetworkService
Host: ads.google.com

&gt;&gt;&gt;&gt; HEADERS &lt;&lt;&lt;&lt;&lt;
Authorization: Bearer ya29.Glz-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: text/xml;charset=UTF-8
User-Agent: ZappySysApp
Host: ads.google.com
Content-Length: 291
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

------------------------------------
Response
------------------------------------
POST 1.1 200 OK==&gt; OK

&gt;&gt;&gt;&gt; HEADERS &lt;&lt;&lt;&lt;&lt;
Content-Encoding: 
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Alt-Svc: quic=":443"; ma=2592000; v="35,34"
Transfer-Encoding: chunked
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=UTF-8
Date: Sun, 26 Feb 2017 01:18:32 GMT
Expires: Sun, 26 Feb 2017 01:18:32 GMT
Server: GSE

&gt;&gt;&gt;&gt; Cookies &lt;&lt;&lt;&lt;&lt;

&gt;&gt;&gt;&gt; CONTENT &lt;&lt;&lt;&lt;&lt;

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;requestId&gt;27ab3d2e4e1fcb8f444b317d0b0f871d&lt;/requestId&gt;
			&lt;responseTime&gt;50&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;getAllNetworksResponse xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;rval&gt;
				&lt;id&gt;551196&lt;/id&gt;
				&lt;displayName&gt;XFP sandbox property&lt;/displayName&gt;
				&lt;networkCode&gt;238897396&lt;/networkCode&gt;
				&lt;propertyCode&gt;ca-pub-2799179143725683&lt;/propertyCode&gt;
				&lt;timeZone&gt;America/New_York&lt;/timeZone&gt;
				&lt;currencyCode&gt;USD&lt;/currencyCode&gt;
				&lt;effectiveRootAdUnitId&gt;237897516&lt;/effectiveRootAdUnitId&gt;
				&lt;isTest&gt;true&lt;/isTest&gt;
			&lt;/rval&gt;
		&lt;/getAllNetworksResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
&nbsp;</li>
</ol>
<h2>How to generate SOAP Request Body using SoapUI tool</h2>
<p>This section describes how to create DoubleClick SOAP API Request Body (XML fragment) for any DFP SOAP API call described anywhere in this article.</p>
<ol>
<li><a href="https://www.soapui.org/downloads/soapui.html" target="_blank" rel="noopener">Download SoapUI</a> (Its free third party tool to test SOAP API). SoapUI can help you to generate XML Request BODY easily from WSDL file provided by API Vendor. You can also test your service by supplying parameters.</li>
<li>Now download WDSL xml for appropriate API calls you want to make. Assume that you want to call  <strong>getAllNetworksResponse</strong> API found under <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService" target="_blank" rel="noopener">NetworkService</a>. For that first navigate to help file page and open help page. Make sure you select correct version from help navigation. Copy WSDL link and open in new browser window. Save XML to local disk (e.g. c:\api\dfp_networkservice_wsdl.xml (See below screenshot how to find DFP API WSDL link)
<div id="attachment_1043" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/get-dftp-soap-api-wsdl-doubleclick-web-service.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1043" class="wp-image-1043" src="//zappysys.com/blog/wp-content/uploads/2017/02/get-dftp-soap-api-wsdl-doubleclick-web-service.png" alt="How to get Google DFP API WSDL URL (Used to generate POST Body)" width="600" height="501" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/get-dftp-soap-api-wsdl-doubleclick-web-service.png 969w, https://zappysys.com/blog/wp-content/uploads/2017/02/get-dftp-soap-api-wsdl-doubleclick-web-service-300x250.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-1043" class="wp-caption-text">How to get Google DFP API WSDL URL (Used to generate POST Body)</p></div></li>
<li>Once SoapUI is downloaded and installed click <strong>File</strong> menu &gt; <strong>Create New SOAP Project</strong> option</li>
<li>Name your project (e.g. DFP API) and specify WSDL URL or File Path if it was saved locally (e.g. c:\api\dfp_networkservice_wsdl.xml) and click OK</li>
<li>Now navigate to API Action for which you would like to get Body. Click Request node (If missing create new) and edit request. You may see XML like below (If some optional parameters not visible in XML then click Re-create request with optional parameters button from toolbar)
<div id="attachment_1044" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-generate-soap-request-body-from-wsdl.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1044" class="wp-image-1044" src="//zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-generate-soap-request-body-from-wsdl.png" alt="Call Google DFP API - Generate SOAP Request Body XML using SoapUI (Google DoubleClick Web Service)" width="600" height="284" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-generate-soap-request-body-from-wsdl.png 727w, https://zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-generate-soap-request-body-from-wsdl-300x142.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-1044" class="wp-caption-text">Call Google DFP API &#8211; Generate SOAP Request Body XML using SoapUI (Google DoubleClick Web Service)</p></div></li>
<li>Edit necessary parameters from above XML code and copy to Body of SSIS REST API Task.</li>
</ol>
<h2>Creating test network &#8211; DFP Sandbox</h2>
<p>Very first step we recommend before testing DFP API call is <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService#makeTestNetwork">create test network</a>. You can call DFP API against LIVE network but not recommended if you are calling create/update API.</p>
<p>To create test network you can follow exact same steps described in the previous section except the Body step (Step#12). Use following Request body to call makeTestNetwork command.</p>
<h3>API makeTestNetwork &#8211; Request</h3>
<p>URL: https://ads.google.com/apis/ads/publisher/v201702/NetworkService<br />
Body (see below):</p><pre class="crayon-plain-tag">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
   &lt;soapenv:Header&gt;
      &lt;v20:RequestHeader/&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
      &lt;v20:makeTestNetwork/&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre><p>
Once you click Test you may receive following response. Note your network code (e.g. 1122334455 from below). This network code is used in pretty much all DFP API to view or manage ad network related items or properties.</p>
<h3>API makeTestNetwork &#8211; Response</h3>
<pre class="crayon-plain-tag">&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;requestId&gt;ba61d79efee325bf4b5aa45c46836021&lt;/requestId&gt;
			&lt;responseTime&gt;1021&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;makeTestNetworkResponse xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;rval&gt;
				&lt;id&gt;551196&lt;/id&gt;
				&lt;displayName&gt;XFP sandbox property&lt;/displayName&gt;
				&lt;networkCode&gt;1122334455&lt;/networkCode&gt;
				&lt;propertyCode&gt;ca-pub-2799179143725683&lt;/propertyCode&gt;
				&lt;timeZone&gt;America/Los_Angeles&lt;/timeZone&gt;
				&lt;currencyCode&gt;USD&lt;/currencyCode&gt;
				&lt;effectiveRootAdUnitId&gt;237897516&lt;/effectiveRootAdUnitId&gt;
				&lt;isTest&gt;true&lt;/isTest&gt;
			&lt;/rval&gt;
		&lt;/makeTestNetworkResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
Above response contains test networkcode copy that code becuase you will need in almost every API call you make later. You can only have one test network. If test network is already created and you try to execute above code then you may receive error  <strong>AuthenticationError.GOOGLE_ACCOUNT_ALREADY_ASSOCIATED_WITH_NETWORK</strong></p>
<p>You can also get network code using two different ways.</p>
<ul>
<li>Visit your DFP console homepage by visiting <a href="https://www.google.com/dfp/" target="_blank" rel="noopener">https://www.google.com/dfp/</a> and you will see network name and code in the top potion. Also its listed in the URL (e.g. https://www.google.com/dfp/1234567)</li>
<li>Another way to get available networks for your login is to visit DFP API Play ground here <a href="https://dfp-playground.appspot.com/" target="_blank" rel="noopener">https://dfp-playground.appspot.com/</a> and you will see network list in the dropdown ( name and network code)</li>
</ul>
<h2>How to Create new Ad Units</h2>
<p>Now lets look at an example which will create few Ad Units by calling <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/InventoryService#createAdUnits" target="_blank" rel="noopener">createAdUnits</a> API. If you are creating Ad Unit at the root level then you will need to specify correct Parent ID (i.e  effectiveRootAdUnitId). To obtain that Parent ID you may have to call  <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService#getcurrentnetwork" target="_blank" rel="noopener">getCurrentNetwork</a> API. In the response you will see effectiveRootAdUnitId.</p>
<p>There is another way to know effectiveRootAdUnitId or Id of any Ad Units which can be Parent for new AdUnit. Goto google.com/dfp &gt; Click Inventory Tab &gt; Click Ad Units Side menu &gt; Click Download ad units hyper link. You can also download AdUnits as CSV file from DFP Portal and look for Ad Units which are created at the root. Parent ID column for Root level Ad Units is basically called effectiveRootAdUnitId.</p>
<p>Now lets look at how to get EffectiveRootID by calling <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/NetworkService#getcurrentnetwork" target="_blank" rel="noopener">getCurrentNetwork</a>.</p>
<h3>API getCurrentNetwork &#8211; Request</h3>
<p>URL: https://ads.google.com/apis/ads/publisher/v201702/NetworkService<br />
Body (see below):</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;soap:Header&gt;
	&lt;RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
		&lt;networkCode xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;1122334455&lt;/networkCode&gt;
		&lt;applicationName xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;ZappySysApp&lt;/applicationName&gt;
	&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;getCurrentNetwork xmlns="https://www.google.com/apis/ads/publisher/v201608" /&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
&nbsp;</p>
<h3>API getCurrentNetwork &#8211; Response</h3>
<pre class="crayon-plain-tag">&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;requestId&gt;81d1b00e8fbfb862129eb2dd485cf7bb&lt;/requestId&gt;
			&lt;responseTime&gt;4507&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;getCurrentNetworkResponse xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;rval&gt;
				&lt;id&gt;551196&lt;/id&gt;
				&lt;displayName&gt;XFP sandbox property&lt;/displayName&gt;
				&lt;networkCode&gt;1122334455&lt;/networkCode&gt;
				&lt;propertyCode&gt;ca-pub-2799179143725683&lt;/propertyCode&gt;
				&lt;timeZone&gt;America/New_York&lt;/timeZone&gt;
				&lt;currencyCode&gt;USD&lt;/currencyCode&gt;
				&lt;effectiveRootAdUnitId&gt;237897516&lt;/effectiveRootAdUnitId&gt;
				&lt;isTest&gt;true&lt;/isTest&gt;
			&lt;/rval&gt;
		&lt;/getCurrentNetworkResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
&nbsp;</p>
<p>If you want to save single Element Value from Response into SSIS Variable then perform following steps (example of how to get just effectiveRootAdUnitId from above response)</p>
<ol>
<li>On REST API Task &gt; Go to Response Tab &gt; Select Response Content Type = XML</li>
<li>Enter following expression in the XPath filter<br />
<pre class="crayon-plain-tag">//*[local-name() = 'effectiveRootAdUnitId']</pre>
</li>
<li>Check Save response content option</li>
<li>Select Variable from Dropdown &#8211; Click New Variable &gt; Name it RootAdUnitId.</li>
<li>Click Test Request Button to test&#8230;. In the content textbox you will now see only Numeric value extracted by Filter</li>
</ol>
<div id="attachment_1050" style="width: 832px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-save-response-into-variable-xpath-jsonpath-filter-extract-value.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1050" class="size-full wp-image-1050" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-save-response-into-variable-xpath-jsonpath-filter-extract-value.png" alt="SSIS REST Api Task - How to extract single vale from response and save to SSIS variable" width="822" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-save-response-into-variable-xpath-jsonpath-filter-extract-value.png 822w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-save-response-into-variable-xpath-jsonpath-filter-extract-value-300x225.png 300w" sizes="(max-width: 822px) 100vw, 822px" /></a><p id="caption-attachment-1050" class="wp-caption-text">SSIS REST Api Task &#8211; How to extract single vale from response and save to SSIS variable</p></div>
<p>Once you know Parent ID for your AdUnit now lets look at how to create Ad Units by calling <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/InventoryService#createAdUnits" target="_blank" rel="noopener">createAdUnits</a></p>
<h3>API createAdUnits &#8211; Request</h3>
<p>URL: https://ads.google.com/apis/ads/publisher/v201702/InventoryService<br />
Body (see below):</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
	&lt;soap:Header&gt;
		&lt;RequestHeader xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;networkCode xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;1122334455&lt;/networkCode&gt;
			&lt;applicationName xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;ZappySysApp&lt;/applicationName&gt;
		&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;createAdUnits xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;adUnits&gt;
				&lt;parentId&gt;237897516&lt;/parentId&gt;
				&lt;name&gt;Ad_Unit_0&lt;/name&gt;
				&lt;description&gt;Ad unit description #0.&lt;/description&gt;
				&lt;targetWindow&gt;BLANK&lt;/targetWindow&gt;
				&lt;adUnitSizes&gt;
					&lt;size&gt;
						&lt;width&gt;300&lt;/width&gt;
						&lt;height&gt;250&lt;/height&gt;
					&lt;/size&gt;
					&lt;environmentType&gt;BROWSER&lt;/environmentType&gt;
				&lt;/adUnitSizes&gt;
			&lt;/adUnits&gt;
			&lt;adUnits&gt;
				&lt;parentId&gt;237897516&lt;/parentId&gt;
				&lt;name&gt;Ad_Unit_1&lt;/name&gt;
				&lt;description&gt;Ad unit description #1.&lt;/description&gt;
				&lt;targetWindow&gt;BLANK&lt;/targetWindow&gt;
				&lt;adUnitSizes&gt;
					&lt;size&gt;
						&lt;width&gt;300&lt;/width&gt;
						&lt;height&gt;250&lt;/height&gt;
					&lt;/size&gt;
					&lt;environmentType&gt;BROWSER&lt;/environmentType&gt;
				&lt;/adUnitSizes&gt;
			&lt;/adUnits&gt;			
		&lt;/createAdUnits&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<h3>API createAdUnits &#8211; Response</h3>
</p><pre class="crayon-plain-tag">&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;requestId&gt;b244d7ba9b65e96fc42b849a7bfb16e4&lt;/requestId&gt;
			&lt;responseTime&gt;331&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;createAdUnitsResponse xmlns="https://www.google.com/apis/ads/publisher/v201608"&gt;
			&lt;rval&gt;
				&lt;id&gt;252312396&lt;/id&gt;
				&lt;parentId&gt;237897516&lt;/parentId&gt;
				&lt;hasChildren&gt;false&lt;/hasChildren&gt;
				&lt;parentPath&gt;
					&lt;id&gt;237897516&lt;/id&gt;
					&lt;name&gt;ca-pub-2799179143725683&lt;/name&gt;
					&lt;adUnitCode&gt;ca-pub-2799179143725683&lt;/adUnitCode&gt;
				&lt;/parentPath&gt;
				&lt;name&gt;Ad_Unit_0&lt;/name&gt;
				&lt;description&gt;Ad unit description#0.&lt;/description&gt;
				&lt;targetWindow&gt;BLANK&lt;/targetWindow&gt;
				&lt;status&gt;ACTIVE&lt;/status&gt;
				&lt;adUnitCode&gt;253312396&lt;/adUnitCode&gt;
				&lt;adUnitSizes&gt;
					&lt;size&gt;
						&lt;width&gt;300&lt;/width&gt;
						&lt;height&gt;250&lt;/height&gt;
						&lt;isAspectRatio&gt;false&lt;/isAspectRatio&gt;
					&lt;/size&gt;
					&lt;environmentType&gt;BROWSER&lt;/environmentType&gt;
					&lt;fullDisplayString&gt;300x250&lt;/fullDisplayString&gt;
				&lt;/adUnitSizes&gt;
				&lt;mobilePlatform&gt;SITE&lt;/mobilePlatform&gt;
				&lt;explicitlyTargeted&gt;false&lt;/explicitlyTargeted&gt;
				&lt;inheritedAdSenseSettings&gt;
					&lt;value&gt;
						&lt;adSenseEnabled&gt;true&lt;/adSenseEnabled&gt;
						&lt;borderColor&gt;FFFFFF&lt;/borderColor&gt;
						&lt;titleColor&gt;0000FF&lt;/titleColor&gt;
						&lt;backgroundColor&gt;FFFFFF&lt;/backgroundColor&gt;
						&lt;textColor&gt;000000&lt;/textColor&gt;
						&lt;urlColor&gt;008000&lt;/urlColor&gt;
						&lt;adType&gt;TEXT_AND_IMAGE&lt;/adType&gt;
						&lt;borderStyle&gt;DEFAULT&lt;/borderStyle&gt;
						&lt;fontFamily&gt;DEFAULT&lt;/fontFamily&gt;
						&lt;fontSize&gt;DEFAULT&lt;/fontSize&gt;
					&lt;/value&gt;
				&lt;/inheritedAdSenseSettings&gt;
				&lt;lastModifiedDateTime&gt;
					&lt;date&gt;
						&lt;year&gt;2017&lt;/year&gt;
						&lt;month&gt;2&lt;/month&gt;
						&lt;day&gt;27&lt;/day&gt;
					&lt;/date&gt;
					&lt;hour&gt;7&lt;/hour&gt;
					&lt;minute&gt;23&lt;/minute&gt;
					&lt;second&gt;32&lt;/second&gt;
					&lt;timeZoneID&gt;PST8PDT&lt;/timeZoneID&gt;
				&lt;/lastModifiedDateTime&gt;
				&lt;smartSizeMode&gt;NONE&lt;/smartSizeMode&gt;
				&lt;isSharedByDistributor&gt;false&lt;/isSharedByDistributor&gt;
				&lt;isSetTopBoxEnabled&gt;false&lt;/isSetTopBoxEnabled&gt;
			&lt;/rval&gt;
			&lt;rval&gt;
				&lt;id&gt;252312516&lt;/id&gt;
				&lt;parentId&gt;237897516&lt;/parentId&gt;
				&lt;hasChildren&gt;false&lt;/hasChildren&gt;
				&lt;parentPath&gt;
					&lt;id&gt;237897516&lt;/id&gt;
					&lt;name&gt;ca-pub-2799179143725683&lt;/name&gt;
					&lt;adUnitCode&gt;ca-pub-2799179143725683&lt;/adUnitCode&gt;
				&lt;/parentPath&gt;
				&lt;name&gt;Ad_Unit_1&lt;/name&gt;
				&lt;description&gt;Ad unit description#2.&lt;/description&gt;
				&lt;targetWindow&gt;BLANK&lt;/targetWindow&gt;
				&lt;status&gt;ACTIVE&lt;/status&gt;
				&lt;adUnitCode&gt;253312516&lt;/adUnitCode&gt;
				&lt;adUnitSizes&gt;
					&lt;size&gt;
						&lt;width&gt;300&lt;/width&gt;
						&lt;height&gt;250&lt;/height&gt;
						&lt;isAspectRatio&gt;false&lt;/isAspectRatio&gt;
					&lt;/size&gt;
					&lt;environmentType&gt;BROWSER&lt;/environmentType&gt;
					&lt;fullDisplayString&gt;300x250&lt;/fullDisplayString&gt;
				&lt;/adUnitSizes&gt;
				&lt;mobilePlatform&gt;SITE&lt;/mobilePlatform&gt;
				&lt;explicitlyTargeted&gt;false&lt;/explicitlyTargeted&gt;
				&lt;inheritedAdSenseSettings&gt;
					&lt;value&gt;
						&lt;adSenseEnabled&gt;true&lt;/adSenseEnabled&gt;
						&lt;borderColor&gt;FFFFFF&lt;/borderColor&gt;
						&lt;titleColor&gt;0000FF&lt;/titleColor&gt;
						&lt;backgroundColor&gt;FFFFFF&lt;/backgroundColor&gt;
						&lt;textColor&gt;000000&lt;/textColor&gt;
						&lt;urlColor&gt;008000&lt;/urlColor&gt;
						&lt;adType&gt;TEXT_AND_IMAGE&lt;/adType&gt;
						&lt;borderStyle&gt;DEFAULT&lt;/borderStyle&gt;
						&lt;fontFamily&gt;DEFAULT&lt;/fontFamily&gt;
						&lt;fontSize&gt;DEFAULT&lt;/fontSize&gt;
					&lt;/value&gt;
				&lt;/inheritedAdSenseSettings&gt;
				&lt;lastModifiedDateTime&gt;
					&lt;date&gt;
						&lt;year&gt;2017&lt;/year&gt;
						&lt;month&gt;2&lt;/month&gt;
						&lt;day&gt;27&lt;/day&gt;
					&lt;/date&gt;
					&lt;hour&gt;7&lt;/hour&gt;
					&lt;minute&gt;23&lt;/minute&gt;
					&lt;second&gt;32&lt;/second&gt;
					&lt;timeZoneID&gt;PST8PDT&lt;/timeZoneID&gt;
				&lt;/lastModifiedDateTime&gt;
				&lt;smartSizeMode&gt;NONE&lt;/smartSizeMode&gt;
				&lt;isSharedByDistributor&gt;false&lt;/isSharedByDistributor&gt;
				&lt;isSetTopBoxEnabled&gt;false&lt;/isSetTopBoxEnabled&gt;
			&lt;/rval&gt;
				&lt;id&gt;252312876&lt;/id&gt;
				&lt;parentId&gt;237897516&lt;/parentId&gt;
				&lt;hasChildren&gt;false&lt;/hasChildren&gt;
				&lt;parentPath&gt;
					&lt;id&gt;237897516&lt;/id&gt;
					&lt;name&gt;ca-pub-2799179143725683&lt;/name&gt;
					&lt;adUnitCode&gt;ca-pub-2799179143725683&lt;/adUnitCode&gt;
				&lt;/parentPath&gt;
				&lt;name&gt;Ad_Unit_4&lt;/name&gt;
				&lt;description&gt;Ad unit description.&lt;/description&gt;
				&lt;targetWindow&gt;BLANK&lt;/targetWindow&gt;
				&lt;status&gt;ACTIVE&lt;/status&gt;
				&lt;adUnitCode&gt;253312876&lt;/adUnitCode&gt;
				&lt;adUnitSizes&gt;
					&lt;size&gt;
						&lt;width&gt;300&lt;/width&gt;
						&lt;height&gt;250&lt;/height&gt;
						&lt;isAspectRatio&gt;false&lt;/isAspectRatio&gt;
					&lt;/size&gt;
					&lt;environmentType&gt;BROWSER&lt;/environmentType&gt;
					&lt;fullDisplayString&gt;300x250&lt;/fullDisplayString&gt;
				&lt;/adUnitSizes&gt;
				&lt;mobilePlatform&gt;SITE&lt;/mobilePlatform&gt;
				&lt;explicitlyTargeted&gt;false&lt;/explicitlyTargeted&gt;
				&lt;inheritedAdSenseSettings&gt;
					&lt;value&gt;
						&lt;adSenseEnabled&gt;true&lt;/adSenseEnabled&gt;
						&lt;borderColor&gt;FFFFFF&lt;/borderColor&gt;
						&lt;titleColor&gt;0000FF&lt;/titleColor&gt;
						&lt;backgroundColor&gt;FFFFFF&lt;/backgroundColor&gt;
						&lt;textColor&gt;000000&lt;/textColor&gt;
						&lt;urlColor&gt;008000&lt;/urlColor&gt;
						&lt;adType&gt;TEXT_AND_IMAGE&lt;/adType&gt;
						&lt;borderStyle&gt;DEFAULT&lt;/borderStyle&gt;
						&lt;fontFamily&gt;DEFAULT&lt;/fontFamily&gt;
						&lt;fontSize&gt;DEFAULT&lt;/fontSize&gt;
					&lt;/value&gt;
				&lt;/inheritedAdSenseSettings&gt;
				&lt;lastModifiedDateTime&gt;
					&lt;date&gt;
						&lt;year&gt;2017&lt;/year&gt;
						&lt;month&gt;2&lt;/month&gt;
						&lt;day&gt;27&lt;/day&gt;
					&lt;/date&gt;
					&lt;hour&gt;7&lt;/hour&gt;
					&lt;minute&gt;23&lt;/minute&gt;
					&lt;second&gt;32&lt;/second&gt;
					&lt;timeZoneID&gt;PST8PDT&lt;/timeZoneID&gt;
				&lt;/lastModifiedDateTime&gt;
				&lt;smartSizeMode&gt;NONE&lt;/smartSizeMode&gt;
				&lt;isSharedByDistributor&gt;false&lt;/isSharedByDistributor&gt;
				&lt;isSetTopBoxEnabled&gt;false&lt;/isSetTopBoxEnabled&gt;
			&lt;/rval&gt;
		&lt;/createAdUnitsResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<h2>Loading Google DoubleClick data into SQL Server Table</h2>
<p>So far we saw how to make simple DFP API calls without doing any parsing. Now lets look at how to use <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">SSIS XML Source</a> which not only make API calls but it will parse XML Response into rows and columns which can be loaded into target database such as SQL Server, Oracle, MySQL or even Flat File. XML Source also supports pagination so if you have many records it will automatically loop through all response untill all records are fetched.</p>
<h3>Step-By-Step &#8211; Using XML Source to read Google DFP data (Parse into rows and columns)</h3>
<ol>
<li>Assuming you have tested your first DFP API Call (Explianed in the beginning of this article). You must have OAuth connection tested for API call.</li>
<li>Drag new Data flow task from SSIS Toolbox</li>
<li>Inside Data flow designer drag and drop <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZS XML Source</a> from toolbox</li>
<li>Double click XML Source to configure.</li>
<li>Set URL as below<br />
https://ads.google.com/apis/ads/publisher/v201702/InventoryService</li>
<li>Check Use credentials option and from Drop down select OAuth connection manager (created in previous section)</li>
<li>Select Method = POST,</li>
<li>Select Request Content Type = XML (text/xml)</li>
<li>Enter Body as below (Click edit button).<br />
<pre class="crayon-plain-tag">&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
   &lt;soapenv:Header&gt;
      &lt;v20:RequestHeader&gt;
         &lt;v20:networkCode&gt;238897396&lt;/v20:networkCode&gt;
         &lt;v20:applicationName&gt;ZappySysApp&lt;/v20:applicationName&gt;
      &lt;/v20:RequestHeader&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
      &lt;v20:getAdUnitsByStatement&gt;
         &lt;v20:filterStatement&gt;
            &lt;v20:query&gt;WHERE Status='ACTIVE'&lt;/v20:query&gt;
         &lt;/v20:filterStatement&gt;
      &lt;/v20:getAdUnitsByStatement&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre>
Notice that in above we calling <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/InventoryService#getAdUnitsByStatement" target="_blank" rel="noopener">getAdUnitsByStatement </a>API to fetch all Ad Units which are Active. Here is<a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/InventoryService.Statement" target="_blank" rel="noopener"> more information about Query Syntax</a> for any API call getXXXXXXByStaement</li>
<li>Now click on <strong>Select Filter</strong> button and select results node and click OK. If prompted add array to list.
<div id="attachment_1054" style="width: 965px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-api-set-filter.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1054" class="size-full wp-image-1054" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-api-set-filter.png" alt="SSIS XML Source - Get data from Google DFP API using OAuth (Configure URL, Body and Filter)" width="955" height="750" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-api-set-filter.png 955w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-api-set-filter-300x236.png 300w" sizes="(max-width: 955px) 100vw, 955px" /></a><p id="caption-attachment-1054" class="wp-caption-text">SSIS XML Source &#8211; Get data from Google DFP API using OAuth (Configure URL, Body and Filter)</p></div></li>
<li>Click Preview to see data. Click Columns tab to review data types (Auto detected). If you wish to change length or datatype then edit there and check Lock option (Last column)
<div id="attachment_1055" style="width: 669px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-preview-google-dfp-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1055" class="size-full wp-image-1055" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-preview-google-dfp-data.png" alt="SSIS XML Source - Preview Response for Google DoubleClick API Call - Parse into Rows/Columns" width="659" height="272" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-preview-google-dfp-data.png 659w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-preview-google-dfp-data-300x124.png 300w" sizes="(max-width: 659px) 100vw, 659px" /></a><p id="caption-attachment-1055" class="wp-caption-text">SSIS XML Source &#8211; Preview Response for Google DoubleClick API Call &#8211; Parse into Rows/Columns</p></div></li>
<li>Click OK to save UI</li>
<li>Connect XML Source to same target (e.g. OLEDB Destination &#8211; SQL Server Connection)</li>
<li>Run data flow
<div id="attachment_1056" style="width: 602px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-load-into-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1056" class="size-full wp-image-1056" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-load-into-sql-server.png" alt="SSIS Execution - Read from Google DFP and load into SQL Server Table" width="592" height="358" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-load-into-sql-server.png 592w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-get-data-from-google-dfp-doubleclick-load-into-sql-server-300x181.png 300w" sizes="(max-width: 592px) 100vw, 592px" /></a><p id="caption-attachment-1056" class="wp-caption-text">SSIS Execution &#8211; Read from Google DFP and load into SQL Server Table</p></div></li>
</ol>
<h3>Configure Pagination for Google DFP API / PQL Query result</h3>
<p>If you have large dataset to read from DoubleClick API ( when calling API such as <strong>getxxxxxxByStatement</strong>) then we recommend to supply LIMIT and OFFSET clause in your <a href="https://developers.google.com/doubleclick-publishers/docs/pqlreference" target="_blank" rel="noopener">PQL query</a>.</p>
<p>For example if you have 2000 ad units and you want to limit response size by maximum 300 rows then your query can be like below</p><pre class="crayon-plain-tag">--For first request (returns results 1-300)
WHERE Status='ACTIVE' LIMIT 300 OFFSET 0

--For second request (returns results 301-600)
WHERE Status='ACTIVE' LIMIT 300 OFFSET 300

--For third request  (returns results 601-900)
WHERE Status='ACTIVE' LIMIT 300 OFFSET 600

........</pre><p>
This looping logic can be complex to implement if you do manually. But no worry if you are using <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">SSIS XML Source</a>. It comes with many pagination options (<a href="//zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">Click here to read more about pagination</a>)</p>
<p>See below screenshot how to configure Pagination options for Google DoubleClick API. Basically two places you have to change. Inside body you have to set placeholder and change few settings on Pagination Tab.</p>
<div id="attachment_1052" style="width: 726px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-paginate-large-resultset-google-dfp-api-doubleclick-pql-query-paging.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1052" class="size-full wp-image-1052" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-paginate-large-resultset-google-dfp-api-doubleclick-pql-query-paging.png" alt="SSIS XML Source - Configure Pagination for Google DoubleClick API data fetch - PQL LIMIT and OFFSET clause for Google DFP API" width="716" height="608" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-paginate-large-resultset-google-dfp-api-doubleclick-pql-query-paging.png 716w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-paginate-large-resultset-google-dfp-api-doubleclick-pql-query-paging-300x255.png 300w" sizes="(max-width: 716px) 100vw, 716px" /></a><p id="caption-attachment-1052" class="wp-caption-text">SSIS XML Source &#8211; Configure Pagination for Google DoubleClick API data fetch &#8211; PQL LIMIT and OFFSET clause for Google DFP API</p></div>
<div id="attachment_1053" style="width: 715px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-configure-pagination-using-post-data-method-call-google-dfp-api-doubleclick.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1053" class="size-full wp-image-1053" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-configure-pagination-using-post-data-method-call-google-dfp-api-doubleclick.png" alt="SSIS XML Source - Configure Pagination for Google DoubleClick API data fetch - Set Pagination Mode" width="705" height="510" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-configure-pagination-using-post-data-method-call-google-dfp-api-doubleclick.png 705w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-xml-source-configure-pagination-using-post-data-method-call-google-dfp-api-doubleclick-300x217.png 300w" sizes="(max-width: 705px) 100vw, 705px" /></a><p id="caption-attachment-1053" class="wp-caption-text">SSIS XML Source &#8211; Configure Pagination for Google DoubleClick API data fetch &#8211; Set Pagination Mode</p></div>
<h2>Create CSV Report File and Download in GZip format (*.gz)</h2>
<p>Sometime you have to download large amount of data (Possibly millions of rows) in that case Bulk approach would be better. <a href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService" target="_blank" rel="noopener">DFP ReportService API</a> allows to call following APIs which can be used to produce CSV report file in *.gz format and then you can download it using REST API Task.</p>
<p>Below are high level steps you have to perform to produce report file and download it.</p>
<ul>
<li>Create the ReportJob by invoking <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.html#runReportJob">runReportJob</a> command .</li>
<li>Poll the ReportJob object using <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.html#getReportJob">ReportService.getReportJob</a> (This is required because file is not available right away) .</li>
<li>Continue to poll the ReportJob object until the <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.ReportJob.html#reportJobStatus">reportJobStatus</a> field is equal to <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.ReportJobStatus.html#COMPLETED">COMPLETED</a> or <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.ReportJobStatus.html#FAILED">FAILED</a>.</li>
<li>If successful, fetch the URL for downloading the report by invoking <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.html#getReportDownloadURL">getReportDownloadURL</a>.</li>
</ul>
<p>Here is the sample SSIS Package to Perform this Action.</p>
<p><a href="//zappysys.com/blog/wp-content/uploads/2017/02/Google-DoubleClick-API-SSIS-DEMO.zip" target="_blank" rel="noopener">Click here to DFP API download Sample for SSIS</a> SSIS Package (SSIS 2012, 2014, 2016)</p>
<p>See below screenshot how to generate Google DFP Report File and download / extract (Unzip) using Drag and Drop SSIS workflow.</p>
<div id="attachment_1179" style="width: 837px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-doubleclick-soap-create-report-download-file-csv-gzip-format.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1179" class="size-full wp-image-1179" src="//zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-doubleclick-soap-create-report-download-file-csv-gzip-format.png" alt="Create Google DFP Report File (CSV / Gzip) and Download Using SSIS (Example of ReportService functions runReportJob, getReportJob and .getReportDownloadURL)" width="827" height="739" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-doubleclick-soap-create-report-download-file-csv-gzip-format.png 827w, https://zappysys.com/blog/wp-content/uploads/2017/02/google-dfp-api-doubleclick-soap-create-report-download-file-csv-gzip-format-300x268.png 300w" sizes="(max-width: 827px) 100vw, 827px" /></a><p id="caption-attachment-1179" class="wp-caption-text">Create Google DFP Report File (CSV / Gzip) and Download Using SSIS (Example of ReportService functions runReportJob, getReportJob and .getReportDownloadURL)</p></div>
<h3>Call runReportJob (Start DFP Report JOB)</h3>
<p>Very first step to produce DFP Report file is call <a class="codelink" href="https://developers.google.com/doubleclick-publishers/docs/reference/v201702/ReportService.html#runReportJob">ReportService &gt;&gt; runReportJob</a> API. See below Command.</p>
<p><strong>Extract Single XML Node Value from SOAP API Response using XPATH</strong></p>
<p>Once you get response you can extract id of your JOB using XPAth Expression (See REST API Task response settings tab. Change Format to XML and type following XPATH expression. This will look for &lt;id&gt;111111&lt;/id&gt; node anywhere in SOAP response XML and extract value (i.e. 111111 )  .. For screenshot see next section</p><pre class="crayon-plain-tag">//*[local-name() = 'id']</pre><p>
<strong>Request</strong></p><pre class="crayon-plain-tag">POST https://ads.google.com/apis/ads/publisher/v201702/ReportService HTTP/1.1
Authorization: Bearer ya29.xxxxxxxxxxxxxxxxxxxxxAKqG89gM-TpReRXO
User-Agent: ZappySysApp/1.0.2017.10531
Content-Type: text/xml
Accept: */*
Cache-Control: no-cache
Host: ads.google.com
Content-Length: 1018
Expect: 100-continue
Accept-Encoding: gzip, deflate

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
	&lt;soapenv:Header&gt;
		&lt;v20:RequestHeader&gt;
			&lt;v20:networkCode&gt;238897396&lt;/v20:networkCode&gt;
			&lt;v20:applicationName&gt;ZappySysApp&lt;/v20:applicationName&gt;
		&lt;/v20:RequestHeader&gt;
	&lt;/soapenv:Header&gt;
	&lt;soapenv:Body&gt;
		&lt;v20:runReportJob&gt;
			&lt;v20:reportJob&gt;
				&lt;v20:reportQuery&gt;
					&lt;v20:dimensions&gt;DATE&lt;/v20:dimensions&gt;
					&lt;v20:dimensions&gt;LINE_ITEM_ID&lt;/v20:dimensions&gt;
					&lt;v20:dimensions&gt;LINE_ITEM_NAME&lt;/v20:dimensions&gt;
					&lt;v20:dimensions&gt;AD_UNIT_NAME&lt;/v20:dimensions&gt;
					&lt;v20:columns&gt;AD_SERVER_IMPRESSIONS&lt;/v20:columns&gt;
					&lt;v20:columns&gt;AD_SERVER_CLICKS&lt;/v20:columns&gt;
					&lt;v20:dimensionAttributes&gt;LINE_ITEM_COST_TYPE&lt;/v20:dimensionAttributes&gt;
					&lt;v20:dimensionAttributes&gt;LINE_ITEM_GOAL_QUANTITY&lt;/v20:dimensionAttributes&gt;
					&lt;v20:dateRangeType&gt;LAST_MONTH&lt;/v20:dateRangeType&gt;
				&lt;/v20:reportQuery&gt;
			&lt;/v20:reportJob&gt;
		&lt;/v20:runReportJob&gt;
	&lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre><p>
<strong>Response</strong></p><pre class="crayon-plain-tag">HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Date: Fri, 02 Jun 2017 21:23:41 GMT
Expires: Fri, 02 Jun 2017 21:23:41 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="38,37,36,35"
Content-Length: 999

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;requestId&gt;f03e7e474fde2a5f9c5d7c9d7eb83923&lt;/requestId&gt;
			&lt;responseTime&gt;846&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;runReportJobResponse xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;rval&gt;
				&lt;id&gt;10000297829&lt;/id&gt;
				&lt;reportQuery&gt;
					&lt;dimensions&gt;DATE&lt;/dimensions&gt;
					&lt;dimensions&gt;LINE_ITEM_ID&lt;/dimensions&gt;
					&lt;dimensions&gt;LINE_ITEM_NAME&lt;/dimensions&gt;
					&lt;dimensions&gt;AD_UNIT_NAME&lt;/dimensions&gt;
					&lt;adUnitView&gt;TOP_LEVEL&lt;/adUnitView&gt;
					&lt;columns&gt;AD_SERVER_IMPRESSIONS&lt;/columns&gt;
					&lt;columns&gt;AD_SERVER_CLICKS&lt;/columns&gt;
					&lt;dimensionAttributes&gt;LINE_ITEM_COST_TYPE&lt;/dimensionAttributes&gt;
					&lt;dimensionAttributes&gt;LINE_ITEM_GOAL_QUANTITY&lt;/dimensionAttributes&gt;
					&lt;dateRangeType&gt;LAST_MONTH&lt;/dateRangeType&gt;
					&lt;useSalesLocalTimeZone&gt;false&lt;/useSalesLocalTimeZone&gt;
					&lt;includeZeroSalesRows&gt;false&lt;/includeZeroSalesRows&gt;
				&lt;/reportQuery&gt;
			&lt;/rval&gt;
		&lt;/runReportJobResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<h3>Call getReportJob (Poll JOB Status)</h3>
<p>Second step is to make sure is Report Status check. For large report it make take several seconds or minutes before you can get Download URL (See Next Step). If you try to call Next step before Report is ready then you may get error. So better to add Polling logic.</p>
<p><strong>Extract Single XML Node Value from SOAP API Response using XPATH</strong></p>
<p>&nbsp;</p>
<p>Once you get response you can extract status of your JOB using XPAth Expression (See REST API Task response settings tab. Change Format to XML and type following XPATH expression. This will look for &lt;rval&gt;IN_PROGRESS&lt;/rval&gt; node anywhere in SOAP response XML and extract value (i.e. IN_PROGRESS )</p><pre class="crayon-plain-tag">//*[local-name() = 'rval']</pre><p>
<div id="attachment_1182" style="width: 719px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-xml-response-extract-node-value-xpath-soap-body.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1182" class="size-full wp-image-1182" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-xml-response-extract-node-value-xpath-soap-body.png" alt="Extract Single XML Node Value from SOAP API Response - Use XPATH in SSIS" width="709" height="417" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-xml-response-extract-node-value-xpath-soap-body.png 709w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-rest-api-xml-response-extract-node-value-xpath-soap-body-300x176.png 300w" sizes="(max-width: 709px) 100vw, 709px" /></a><p id="caption-attachment-1182" class="wp-caption-text">Extract Single XML Node Value from SOAP API Response &#8211; Use XPATH in SSIS</p></div>
<p><strong>Request</strong></p><pre class="crayon-plain-tag">POST https://ads.google.com/apis/ads/publisher/v201702/ReportService HTTP/1.1
Authorization: Bearer ya29.xxxxxxxxxxxxxxxxxxXmWqmq
User-Agent: ZappySysApp/1.0.2017.10531
Content-Type: text/xml
Accept: */*
Cache-Control: no-cache
Host: ads.google.com
Content-Length: 524
Expect: 100-continue
Accept-Encoding: gzip, deflate

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
   &lt;soapenv:Header&gt;
      &lt;v20:RequestHeader&gt;
         &lt;v20:networkCode&gt;238897396&lt;/v20:networkCode&gt;
         &lt;v20:applicationName&gt;ZappySysApp&lt;/v20:applicationName&gt;
      &lt;/v20:RequestHeader&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
      &lt;v20:getReportJobStatus&gt;
       &lt;v20:reportJobId&gt;10000297829&lt;/v20:reportJobId&gt;
      &lt;/v20:getReportJobStatus&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre><p>
<strong>Response</strong></p><pre class="crayon-plain-tag">HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Date: Fri, 02 Jun 2017 21:23:47 GMT
Expires: Fri, 02 Jun 2017 21:23:47 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="38,37,36,35"
Content-Length: 451

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;requestId&gt;d52cb3a3d68af24aec2f9b0284379700&lt;/requestId&gt;
			&lt;responseTime&gt;803&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;getReportJobStatusResponse xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;rval&gt;COMPLETED&lt;/rval&gt;
		&lt;/getReportJobStatusResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
&nbsp;</p>
<h3>Call getReportDownloadURL (Get Download URL)</h3>
<p>Once you get status = COMPLETED in above API Call (i.e.  getReportJobStatus) then you ready to call getReportDownloadURL  to fetch URL which you can download.</p>
<p>Here is the API sample Request and Response</p>
<p><strong>Request</strong></p><pre class="crayon-plain-tag">POST https://ads.google.com/apis/ads/publisher/v201702/ReportService HTTP/1.1
Authorization: Bearer ya29.xxxxxxxxxxxxxxxxxxBp84ltTNyVRb9hlUEWx
User-Agent: ZappySysApp/1.0.2017.10531
Content-Type: text/xml
Accept: */*
Cache-Control: no-cache
Host: ads.google.com
Content-Length: 581
Expect: 100-continue
Accept-Encoding: gzip, deflate

&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="https://www.google.com/apis/ads/publisher/v201702"&gt;
   &lt;soapenv:Header&gt;
      &lt;v20:RequestHeader&gt;
         &lt;v20:networkCode&gt;238897396&lt;/v20:networkCode&gt;
         &lt;v20:applicationName&gt;ZappySysApp&lt;/v20:applicationName&gt;
      &lt;/v20:RequestHeader&gt;
   &lt;/soapenv:Header&gt;
   &lt;soapenv:Body&gt;
      &lt;v20:getReportDownloadURL&gt;
       &lt;v20:reportJobId&gt;10000297829&lt;/v20:reportJobId&gt;
       &lt;v20:exportFormat&gt;CSV_DUMP&lt;/v20:exportFormat&gt;
      &lt;/v20:getReportDownloadURL&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;</pre><p>
&nbsp;</p>
<p><strong>Response</strong></p><pre class="crayon-plain-tag">HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Date: Fri, 02 Jun 2017 21:23:49 GMT
Expires: Fri, 02 Jun 2017 21:23:49 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="38,37,36,35"
Content-Length: 1039

&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
	&lt;soap:Header&gt;
		&lt;ResponseHeader xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;requestId&gt;8e5ac0bbeb8e88c180ea442fc5378d99&lt;/requestId&gt;
			&lt;responseTime&gt;1957&lt;/responseTime&gt;
		&lt;/ResponseHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;getReportDownloadURLResponse xmlns="https://www.google.com/apis/ads/publisher/v201702"&gt;
			&lt;rval&gt;https://storage.googleapis.com/dfp-report-export/caxxxxxxxx-xxxxxxxxxxxxxxb?GoogleAccessId=3769xxxxxxxxxxx-qxxxxxxxxxxxxxxxxsqdb5dvi8g@developer.gserviceaccount.com&amp;amp;Expires=1496438929&amp;amp;Signature=vnhCiAIqd%2BFgWCtAHo9roFOI3W%2BveUTYuSvyBQ9gtMI2HDTXOCVDh7wzUV%2BPBJZZghaL6k8wKYq33GA4NpjZVNYuaAgPLWgGwAUPdtioHRi%2Bt3Eymp%2FAPRGIoos0ekP3O7l%2FPNPxenC6UTP087HV3j06V%2Fuui9ixpKZWGCK8r56oUPj6S8q1hG95Ns3d3sEcuz3%2BkShu6GYG5mqir5vjtZPuzwsr%2F96G5Kk123mke%2B%2FIVRJGoqnCMghNWtIG1yR1IdZx%2FIpit%2FnaJ9HP6IvAr3oMIXkQ3cHv%2FtOhXGy9dTG34q%2FKDbtkSJAayHgjlSLPGKucygcXBhUrbywBu8Y77A%3D%3D&lt;/rval&gt;
		&lt;/getReportDownloadURLResponse&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<strong>Extract Single XML Node Value from SOAP API Response using XPATH</strong></p>
<p>Once you get response you can extract status of your JOB using XPAth Expression (See REST API Task response settings tab. Change Format to XML and type following XPATH expression. This will look for &lt;rval&gt;https://storage.googleapis.com/dfp-report-export/caxx&#8230;&#8230;&#8230;.&lt;/rval&gt; node anywhere in SOAP response XML and extract value (i.e. URL)</p>
<h3>Download File Using REST API Task</h3>
<p>Once you get URL its time to download it. You can use REST API Task to download the file. On Response Setting Tab specify full file path (e.g. c:\report_csv.gz) and make sure Binary option is checked (Found next to the Save Path)</p>
<h2>Making things dynamic</h2>
<p>If you want to supply certain parameters at runtime (e.g. from SSIS Variable) rather than hard code then you can use Variable Placeholders any where in Request Body, URL or Headers. Click Insert Variable option found in Edit screen</p>
<p>Here is an example of dynamic URL (API Version stored in SSIS Variable)</p><pre class="crayon-plain-tag">https://ads.google.com/apis/ads/publisher/{{User::ApiVer}}/NetworkService</pre><p>
<h2>Deployment to Production</h2>
<p>When you ready to deploy your SSIS Package to production make sure to change Test NetworkCode supplied inside Request Body to your Production Ad Network. Also Set RefreshToken Property of OAuth Connection Manager (Get it from Backup file saved when you created OAuth connection first time). Once you set RefreshToken of connection manager you won&#8217;t have to Login again to get a new token.</p>
<h2>Conclusion</h2>
<p>Traditionally if you wanted to integrate Google DFP API (DoubleClick API) calls inside your ETL workflow then it required some sort of coding effort (e.g. Use C# SDK, JAVA SDK or Python SDK). Coding effort is not only time consuming and expensive but also hard to maintain for any non-coder (e.g. ETL Developer or DBA).<br />
Thanks to <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> which changed the way developers do API integration. Now you can reduce time to implement and total cost of you API integration project significantly by using drag and drop approach. This approach is not only easy to maintain but also fast and high quality. You can use ZappySys REST/SOAP SSIS Connectors and SSIS Tasks for any API integration project such as Google DFP API. <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">Try SSIS PowerPack</a> for free to explore possibilities. If you have any issue with your integration <a href="//zappysys.com/support/">Contact Support</a></p>
<p>The post <a href="https://zappysys.com/blog/calling-google-dfp-api-with-ssis-doubleclick-soap-api/">How to call Google DFP API with SSIS &#8211; DoubleClick</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to read / write Google SpreadSheet using SSIS</title>
		<link>https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 24 Sep 2016 23:21:11 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS REST API Task]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[Google Drive]]></category>
		<category><![CDATA[Google Spreadsheet]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[oauth2]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis rest api task]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=798</guid>

					<description><![CDATA[<p>Introduction In this post you will learn how to get data from Google SpreadSheet (REST API) using SSIS. We will use drag and drop REST API connectors from SSIS PowerPack. No need to download any SDK or learn programming language (e.g. JAVA, C#, Ruby, Python) when you use SSIS PowerPack Connectors. We will use Google [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/">How to read / write Google SpreadSheet using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>UPDATE:</strong> ZappySys has released a brand new <a href="https://zappysys.com/api/integration-hub/google-sheets-connector/">API Connector for Google Sheets Online</a> which makes it much simpler to <strong>Read/Write Google Sheets 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="//zappysys.com/blog/wp-content/uploads/2016/09/google-sheets-api-integration.png"><img loading="lazy" decoding="async" class="alignleft wp-image-1670" src="//zappysys.com/blog/wp-content/uploads/2016/09/google-sheets-api-integration.png" alt="" width="150" height="171" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/google-sheets-api-integration.png 350w, https://zappysys.com/blog/wp-content/uploads/2016/09/google-sheets-api-integration-263x300.png 263w" sizes="(max-width: 150px) 100vw, 150px" /></a>In this post you will learn how to <em>get data from Google SpreadSheet</em> (REST API) using SSIS. We will use drag and drop REST API connectors from <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a>. No need to download any SDK or learn programming language (e.g. JAVA, C#, Ruby, Python) when you use SSIS PowerPack Connectors. We will use Google Drive API and Google Sheets API to get file list and export SpreadSheet as CSV file in few clicks (Using OAuth 2.0 connection in SSIS).</p>
<p>In this tutorial we will use <a href="//zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to call some ad-hoc API (e.g. get File List from Google Drive) and save output into Variable or File. We will use <a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth connection</a> along with <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZappySys JSON Source connector</a> to read data from Google SpreadSheet (Use Drive API) and load into SQL Server (Export Google SpreadSheet to CSV).</p>
<h2>Create Google API Project</h2>
<p>First step to access any Google API is create an API Project in Google Console. If you don&#8217;t want to go through this then Skip this Step-1 and in the next section select Default OAuth App option on OAth Connection Manager (This is the most easiest option for now unless you want to use your own OAuth App).</p>
<p><a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Check this article</a> for step-by-step instructions. When you follow these instructions make sure you enable Google Drive API (In the article it shows how to enable YouTube API as an example but you will need to enable Drive API for this article).</p>
<h2>Create OAuth Connection Manager in SSIS</h2>
<p>Once you create Google API project and obtained Client ID and Client Secret your next step is to create <a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> in SSIS. ZappySys OAuth connection manager comes with many predefined OAuth Providers (e.g. Facebook, Twitter, Google etc) but you can also define custom OAuth settings for any OAuth enabled API.</p>
<p>To create SSIS OAuth 2.0 Connection for Google API perform following steps.</p>
<ol>
<li>Download and Install SSIS PowerPack</li>
<li>Create new SSIS Package</li>
<li>Right click in Connection Manager Area and Click &#8220;New Connection&#8221;</li>
<li>When prompted select ZS-OAUTH connection type</li>
<li>On the OAuth Connection Manager Select Provider=<strong>Google Sheets + Drive</strong>.</li>
<li>You can keep &#8220;Use Default App&#8221; selected or choose Custom App. <a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Click here to learn &#8211; how to register Custom Google App</a></li>
<li>If you choose the Custom App option then <strong>enter the below scopes</strong> (or click Select Scopes). If you choose the default app then it&#8217;s not required.
<p>This will allow read / write access to Drive Files or Sheet (E.g. Reading file content / Export file to CSV). You can use Scope browser to see many other available permissions.</p><pre class="crayon-plain-tag">https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/spreadsheets.readonly</pre><p>
Click Generate Token button.</p>
<div id="attachment_847" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-oauth-connection-google-drive-api-access-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-847" class="wp-image-847" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-oauth-connection-google-drive-api-access-file.png" alt="SSIS OAuth Connection Manager - Access Google Drive API using OAuth 2.0" width="600" height="351" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-oauth-connection-google-drive-api-access-file.png 957w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-oauth-connection-google-drive-api-access-file-300x176.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-847" class="wp-caption-text">SSIS OAuth Connection Manager &#8211; Access Google Drive API using OAuth 2.0</p></div></li>
<li>You will see UI as below&#8230; Click Accept (You may have to scroll to see that button sometimes)</li>
<li>Click Test to see connection is working.</li>
</ol>
<p><strong>NOTE:</strong> If you don&#8217;t want to use Default OAuth App provided by ZappySys then select &#8220;Use Custom OAuth App&#8221; option (App created in previous section) specify your ClientID, ClientSecret.</p>
<h2>Find Google Sheet ID for API call</h2>
<p>Before we can read or write Sheet data in SSIS we need to know Google Driver File ID. We will use this ID in next few sections.</p>
<p>Easiest way to find File ID is look at the URL like below. If you need to know ID at runtime dynamically then refer last section.</p>
<p>&nbsp;</p>
<div id="attachment_8450" style="width: 806px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8450" class="size-full wp-image-8450" src="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png" alt="Get Google Drive File ID for API call (Sheet ID)" width="796" height="286" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call.png 796w, https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call-300x108.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/obtain-google-sheet-id-for-api-call-768x276.png 768w" sizes="(max-width: 796px) 100vw, 796px" /></a><p id="caption-attachment-8450" class="wp-caption-text">Get Google Drive File ID for API call (Sheet ID)</p></div>
<h2>Reading Google SpreadSheet Data in SSIS</h2>
<p>Basically there are two ways you can export / read Google SpreadSheet data.</p>
<ul>
<li>Method-1 : Read Google SpreadSheet using SSIS JSON / REST API Source
<ul>
<li>In this approach we directly pull data from SpreadSheet using <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get" target="_blank" rel="noopener">Core Google SpreadSheet.Values API</a> to read particular Tab from Sheet and you can also specify Range. This is most effective way to read. Make sure you have <strong>v2.5.0.10807 or higher version</strong> (released after Aug 03 2017). New version added <a href="//zappysys.com/blog/parse-multi-dimensional-json-array-ssis/" target="_blank" rel="noopener">2D array transformation options to parse multi-dimensional arrays</a> found in SpreadSheet API JSON response.</li>
</ul>
</li>
<li>Method-2 : Read Google SpreadSheet using Flat File Source (as CSV)
<ul>
<li>Another approach is export SpreadSheet as CSV format. Then use Flat File Source to read that data and load into Target (E.g. SQL Server)</li>
</ul>
</li>
</ul>
<h3>Method-1 : Read Google SpreadSheet using SSIS JSON / REST API Source</h3>
<p>Now lets look at real steps to read Google SpreadSheet. To get values from specific tab and specific cell-row range you have to use <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get" target="_blank" rel="noopener">Google SpreadSheet.Values API</a></p>
<p>In this example we will load below Google Spreadsheet into SQL Server</p>
<p><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-reading-google-spreadsheet-example.png"><img loading="lazy" decoding="async" class="alignnone wp-image-1657" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-reading-google-spreadsheet-example.png" alt="" width="521" height="327" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-reading-google-spreadsheet-example.png 777w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-reading-google-spreadsheet-example-300x188.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-reading-google-spreadsheet-example-768x482.png 768w" sizes="(max-width: 521px) 100vw, 521px" /></a></p>
<h4><strong>Step-By-Step : Loading Google SpreadSheet into SQL Server using SSIS</strong></h4>
<ol>
<li>Drag and drop data flow on the control flow designer surface</li>
<li>Double click data flow and you will see SSIS Toolbox refreshed with new components</li>
<li>Drag ZS JSON Source from SSIS Toolbox onto Data flow designer surface</li>
<li>Double click JSON SOurce and configure below setting
<ol>
<li>Enter your Spreadsheet URL in the following format<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{your-file-id}/values/{cell-range}</pre>
For example purpose we will use <a href="https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0" target="_blank" rel="noopener">this public SpreadSheet provided by Google</a>. If spreadsheet fileid is <strong>1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms</strong> (see previous section how to get fileid) and your tab name is <strong>Class Data</strong> and you like to extract data from <strong>A to F</strong> columns <strong>starting from 2nd row</strong> then your Cell range in the URL can be <strong>&#8216;Class Data&#8217;!A2:F</strong><br />
Here is the actual URL we will use for demo<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/values/'Class Data'!A2:F</pre>
&#8212; OR &#8212;<br />
You can also enter like below (If you omit Tab name then first table is used)<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/values/A1:F

--OR-- Use below URL for to supply Column names manually (Start from A2)

https://sheets.googleapis.com/v4/spreadsheets/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/values/A2:F</pre>
You can also enter like below, specify first row and last row<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/values/A1:F101</pre>
</li>
<li>Check Use credentials and select OAuth connection we created in previous section</li>
<li>Click on Select Filter and select values node and click OK  or you can directly enter following filter.<br />
<pre class="crayon-plain-tag">$.values[*]</pre>
<div id="attachment_1652" style="width: 894px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1652" class="size-full wp-image-1652" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api.png" alt="Configure SSIS JSON/REST API Source - Read data from Google SpreadSheet API " width="884" height="673" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api.png 884w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-300x228.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-768x585.png 768w" sizes="(max-width: 884px) 100vw, 884px" /></a><p id="caption-attachment-1652" class="wp-caption-text">Configure SSIS JSON/REST API Source &#8211; Read data from Google SpreadSheet API</p></div></li>
<li>Now click on array Transformation tab. Now we will show you two different ways to configure column names.</li>
<li><strong>Method-1: Auto Detect Column Names</strong> (added in <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/release-notes.htm" target="_blank" rel="noopener">version 3.1.2</a>)<br />
In recent version we added column less array transformation where we have option to detect first record as column name.</p>
<ol>
<li>Select Transform Type as Column less array</li>
<li>Check option First line has column names like below example (Ignore direct Sample JSON &#8211; We provided for demo only. In your case it will be URL)
<div id="attachment_9118" style="width: 645px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/08/columnless-array-first-line-has-names-pattern.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9118" class="wp-image-9118 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/08/columnless-array-first-line-has-names-pattern.png" alt="JSON With 2D Array Pattern - Column names in First Row (Google Sheets API Pattern)" width="635" height="669" srcset="https://zappysys.com/blog/wp-content/uploads/2017/08/columnless-array-first-line-has-names-pattern.png 635w, https://zappysys.com/blog/wp-content/uploads/2017/08/columnless-array-first-line-has-names-pattern-285x300.png 285w" sizes="(max-width: 635px) 100vw, 635px" /></a><p id="caption-attachment-9118" class="wp-caption-text">JSON With 2D Array Pattern &#8211; Column names in First Row (Google Sheets API Pattern)</p></div></li>
</ol>
</li>
<li><strong>Method-2: Manually Enter Column Names</strong> (For old version)
<ol>
<li>Select Transform simple 2D array option from dropdown</li>
<li>Check Specify columns list manually</li>
<li>Enter column names (Must match the order and count based on range you selected)<br />
<pre class="crayon-plain-tag">Student Name,Gender,Class Level,Home State,Major,Extracurricular Activity</pre>
<div id="attachment_1653" style="width: 878px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1653" class="size-full wp-image-1653" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-2.png" alt="Configure SSIS JSON/REST API Source 2D Array Transformation for Google SpreadSheet API " width="868" height="255" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-2.png 868w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-2-300x88.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-2-768x226.png 768w" sizes="(max-width: 868px) 100vw, 868px" /></a><p id="caption-attachment-1653" class="wp-caption-text">Configure SSIS JSON/REST API Source 2D Array Transformation for Google SpreadSheet API</p></div></li>
</ol>
</li>
<li>Now click Preview to see the data
<div id="attachment_1654" style="width: 872px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-3.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1654" class="size-full wp-image-1654" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-3.png" alt="Configure SSIS JSON/REST API Source - Preview Google SpreadSheet Data" width="862" height="678" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-3.png 862w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-3-300x236.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-json-source-read-google-spreadsheet-data-rest-api-3-768x604.png 768w" sizes="(max-width: 862px) 100vw, 862px" /></a><p id="caption-attachment-1654" class="wp-caption-text">Configure SSIS JSON/REST API Source &#8211;<br />Preview Google SpreadSheet Data</p></div></li>
<li>Click OK to save UI</li>
<li>Attach your JSON Source to target (e.g. OLEDB Destination for SQL Server Table).</li>
<li>Configure Destination
<div id="attachment_1655" style="width: 825px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-google-spreadsheet-to-sql-server-load.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1655" class="size-full wp-image-1655" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-google-spreadsheet-to-sql-server-load.png" alt="Configure SQL Server destination for Google SpreadSheet to SQL Data load" width="815" height="489" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-google-spreadsheet-to-sql-server-load.png 815w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-google-spreadsheet-to-sql-server-load-300x180.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-configure-google-spreadsheet-to-sql-server-load-768x461.png 768w" sizes="(max-width: 815px) 100vw, 815px" /></a><p id="caption-attachment-1655" class="wp-caption-text">Configure SQL Server destination for Google SpreadSheet to SQL Data load</p></div></li>
<li>Execute SSIS Package to load Google SpreadSheet data int SQL Server
<div id="attachment_1656" style="width: 628px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-loading-google-spreadsheet-to-sql-server-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1656" class="size-full wp-image-1656" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-loading-google-spreadsheet-to-sql-server-example.png" alt="SSIS Example -Loading data from Google SpreadSheet into SQL Server Table" width="618" height="311" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-loading-google-spreadsheet-to-sql-server-example.png 618w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-loading-google-spreadsheet-to-sql-server-example-300x151.png 300w" sizes="(max-width: 618px) 100vw, 618px" /></a><p id="caption-attachment-1656" class="wp-caption-text">SSIS Example -Loading data from Google SpreadSheet into SQL Server Table</p></div></li>
</ol>
</li>
</ol>
<h3>Method-2 : Read Google SpreadSheet using Flat File Source (as CSV)</h3>
<p>Once we have Google Drive fileId we can perform following actions to export data into CSV file format. After that you can easily read CSV using SSIS FlatFile Source and load into SQL Server or other target.</p>
<h4>Export Google SpreadSheet as CSV file using SSIS REST API Task</h4>
<p>Here are the steps to export Google Drive SpreadSheet to CSV file</p>
<ol>
<li>Just like previous section configure REST API Task</li>
<li>Enter following URL (See we used FileId from SSIS variable. You can hardcode too.<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/drive/v3/files/{{User::varFileId}}/export?mimeType=text/csv</pre>
</li>
<li>Goto response tab. Check Save response and select &#8220;Save to file option&#8221;.</li>
<li>Enter file path.</li>
<li>Response character set select utf-8 (This will allow Unicode characters in response)</li>
<li>Click Test to see preview
<div id="attachment_850" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-export-google-spreadsheet-to-csv-format-call-google-drive-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-850" class="wp-image-850" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-export-google-spreadsheet-to-csv-format-call-google-drive-api.png" alt="Export Google SpreadSheet to CSV file format using SSIS - Call Google Drive API to Export" width="600" height="503" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-export-google-spreadsheet-to-csv-format-call-google-drive-api.png 701w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-export-google-spreadsheet-to-csv-format-call-google-drive-api-300x252.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-850" class="wp-caption-text">Export Google SpreadSheet to CSV file format using SSIS &#8211; Call Google Drive API to Export</p></div></li>
<li>Click OK to save</li>
</ol>
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: New version now includes CSV Source for API. Use that if you want to consume Google Spread Sheet data in Data Flow. However we still recommend JSON Source (As per previous section to read data. Use CSV export method only if JSON API is not working for you for some reason.</div></div>
<h4>Load Google SpreadSheet data into SQL Server using SSIS (REST API Call)</h4>
<p>Once you export SpreadSheet to CSV file you can easily consume it to load into SQL Server or any Target (e.g. Oracle, MySQL) using Native SSIS FlatFile Source and OLEDB/ADO.net Destination.</p>
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><strong>NOTE:</strong> Using FlatFile Source is not covered in Article. You can find many articles online which shows how to use SSIS FlatFile Source.</div></div>
<h2>Write data to Google Spread Sheet</h2>
<p>Now lets look at how to write to Google SpreadSheet. To write multiple rows in a single request you may use <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate" target="_blank" rel="noopener">batchUpdate API</a>. Also check this link to <a href="https://developers.google.com/sheets/api/guides/values" target="_blank" rel="noopener">learn more</a>.</p>
<p>Below is sample request to write data to columns and some data to rows (set majorDimension = <strong>COLUMNS</strong> to <strong>write vertical</strong> and use <strong>ROWS</strong> to <strong>write horizontally</strong>. You can mix multiple ways just like below example)</p><pre class="crayon-plain-tag">POST 
https://sheets.googleapis.com/v4/spreadsheets/1lkMEgu0zm2Q-cnPeoNZp4hqeIuASxXSpsrxtDDV89tg/values:batchUpdate
Authorization: Bearer ya29.Gl3WBFb3xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
Accept: */*

{
  "valueInputOption": "USER_ENTERED",
  "data": [
    {
      "range": "Sheet2!A1:A4",
      "majorDimension": "COLUMNS",
      "values": [
        ["Item", "Wheel", "Door", "Engine"]
      ]
    },
    {
      "range": "Sheet2!B1:D2",
      "majorDimension": "ROWS",
      "values": [
        ["Cost", "Stocked", "Ship Date"],
        ["$20.50", "4", "3/1/2016"]
      ]
    }
  ]
}</pre><p>
<div id="attachment_2050" style="width: 1282px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2050" class="size-full wp-image-2050" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth.png" alt="Write data to Google SpreadSheet using REST API Task (OAuth 2.0 Connection)" width="1272" height="668" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth.png 1272w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth-300x158.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth-768x403.png 768w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-write-google-spreadsheet-using-rest-api-oauth-1024x538.png 1024w" sizes="(max-width: 1272px) 100vw, 1272px" /></a><p id="caption-attachment-2050" class="wp-caption-text">Write data to Google SpreadSheet using REST API Task (OAuth 2.0 Connection)</p></div>
<p>&nbsp;</p>
<h2>Update Google Sheet Cells &#8211; Single Range (Set Values for multiple cells)</h2>
<p>Now let&#8217;s look at the below example of updating multiple cells in google Sheet. For more information, you can see the <a href="https://developers.google.com/sheets/api/samples/writing" target="_blank" rel="noopener">example here</a>. For parameter detail review this API documentation.</p>
<p>You can use<a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener"> SSIS REST API Task</a> or <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> to achieve Spread Sheet Update scenario. For simple example lets use REST API Task.</p>
<ol>
<li>Drag and Drop ZS REST API Task on the control flow designer</li>
<li>Edit Task and select URL from Connection Method</li>
<li>Select OAuth Connection from the dropdown (Same connection we created in the previous section)</li>
<li>Enter the URL as below. Change Sheet ID, Range designator and API URL Parameters as per your need.<br />
<em>https://sheets.googleapis.com/v4/spreadsheets/<strong>[Sheet-ID-Here]</strong>/values/<strong>[Range-Here]</strong></em>?[<em><strong>Parameters-Here]
</strong></em><strong>Example URL (some part masked with xxxxxxxx):  </strong><br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6xxxxxxxxCHrORJc/values/Sheet1!A2:B4?valueInputOption=USER_ENTERED</pre>
</li>
<li>Change Request Method to <strong>PUT</strong></li>
<li>Change Request Content type to <strong>application/json</strong></li>
<li>Enter Request Body as below (Assuming we need to update 4 cells)<br />
<pre class="crayon-plain-tag">{
"majorDimension": "ROWS",
  "values": [
   ["row1_cellA","row1_cellB"],
   ["row2_cellA","row2_cellB"],
  ]
}</pre>
</li>
<li>Click Test Request see it works.
<div id="attachment_4521" style="width: 947px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-update-google-sheet-using-rest-api-multiple-cells.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4521" class="size-full wp-image-4521" src="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-update-google-sheet-using-rest-api-multiple-cells.png" alt="Calling Google Sheet API to Update Multiple Cell Values" width="937" height="948" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-update-google-sheet-using-rest-api-multiple-cells.png 937w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-update-google-sheet-using-rest-api-multiple-cells-297x300.png 297w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-update-google-sheet-using-rest-api-multiple-cells-768x777.png 768w" sizes="(max-width: 937px) 100vw, 937px" /></a><p id="caption-attachment-4521" class="wp-caption-text">Calling Google Sheet API to Update Multiple Cell Values</p></div></li>
</ol>
<h2>Update Google Sheet Cells &#8211; Multiple Ranges</h2>
<p>If you like to update values which needs to define multiple ranges then you need to use <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate" target="_blank" rel="noopener">batchUpdate API</a>. Import changes are you can&#8217;t include Range in the URL like previous example of Single Range Update. Also you have to use POST method and body with multiple ranges.</p>
<p>Example of sheet update with multiple range</p><pre class="crayon-plain-tag">POST https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHxxxxxxxxxxxxxxxc/values:batchUpdate?valueInputOption=USER_ENTERED
Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
  "data": [
    {
      "range": "Sheet1!A2:B3",
      "majorDimension": "ROWS",
      "values": [
        [
          "row1_cellA",
          "row1_cellB"
        ],
        [
          "row2_cellA",
          "row2_cellB"
        ]
      ]
    },
    {
      "range": "Sheet1!D2:E3",
      "majorDimension": "ROWS",
      "values": [
        [
          "row1_cellD",
          "row1_cellE"
        ],
        [
          "row2_cellD",
          "row2_cellE"
        ]
      ]
    }
  ]
}</pre><p>
&nbsp;</p>
<h2>Write SQL Server data to Google Sheet</h2>
<p>Now let&#8217;s look at real world example. How to write data from SQL Server table or other source and send to Google Sheet.</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>Drag source (e.g. OLEDB Source) and configure it to read from source like SQL Server Table
<div id="attachment_7289" style="width: 515px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7289" class="size-full wp-image-7289" src="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png" alt="OLE DB Source - Drag and Drop" width="505" height="190" srcset="https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop.png 505w, https://zappysys.com/blog/wp-content/uploads/2019/06/oledb-source-drag-and-drop-300x113.png 300w" sizes="(max-width: 505px) 100vw, 505px" /></a><p id="caption-attachment-7289" class="wp-caption-text">OLE DB Source &#8211; Drag and Drop</p></div></li>
<li>Drag <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/">ZS JSON Generator</a>.
<ol>
<li>Connect Source to JSON Generator (blue arrow)</li>
<li>Double click it to configure</li>
<li>Select Output Mode as <strong>Single Dataset Array</strong> option for Mode. Enter Some Batch value (e.g. 500) this will make sure we send 500 rows at a time to Google API call. This way if we have many rows its not rejected by API call.</li>
<li>Click <strong>Add element</strong> (Select <strong>Static Element</strong>) . Name: <strong>majorDimension</strong> and Value: <strong>ROWS</strong></li>
<li>Now click Add Document Array icon, name as <strong>values</strong></li>
<li>check Treat as <strong>2D array</strong> option and click OK to save</li>
<li>Now under values node click <strong>Add elements</strong> &gt; Select <strong>Multiple Columns</strong> and Add columns you like to add.</li>
<li>Click OK to save JSON GeneratorBelow is just an example How you can use Batch Settings to create JSON with N rows in each JSON document.<br />
<img decoding="async" src="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2019/02/ssis-generate-json-with-batch-setting.png?resize=720%2C564&amp;ssl=1" alt="Using SSIS JSON Generator Transform with Batch Option (Multiple Records in a single document)" /></li>
</ol>
</li>
<li>Now drag <a href="https://zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">ZS Web API destination</a>
<ol>
<li>Connect JSON Generator to Web API destination (blue arrow)</li>
<li>Double click it to configure</li>
<li>Select same OAuth connection manager created in earlier section (Assuming you had all scopes with write permission)</li>
<li>Now select <strong>Input column</strong> for <strong>Body </strong>(JSON Generator Output)</li>
<li>Enter API call URL as below (Replace <strong>ID</strong> with your own id)<br />
<pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{your-file-id}/values/Sheet1!A2?valueInputOption=USER_ENTERED</pre>
</li>
<li>Select Request Method as <strong>PUT</strong></li>
<li>Select content type as <strong>application/json</strong></li>
<li>You can enter sample Body As below.<br />
<pre class="crayon-plain-tag">{
"majorDimension": "ROWS",
  "values": [
   ["Bob","bob@mycompany.com",55],
   ["Sam","sam@mycompany.com",57]
  ]
}</pre>
</li>
<li>Click Test Request / Response button. Check your Sheet in browser after it see it updates?</li>
<li>If you see <strong>200 OK</strong> response means we are good to go.</li>
<li>Run package and see your real data updated in Sheet.</li>
</ol>
</li>
</ol>
<h2>Format Cells using Google Sheet API</h2>
<p>Now let&#8217;s look at an example to format cell using Google Sheet API (e.g. Change Font, Color, Border, Background). For more information review <a href="https://developers.google.com/sheets/api/samples/formatting" target="_blank" rel="noopener">this API documentation</a>.</p>
<p>To format Sheet you first need to get SheetID  (keep in mind this is not same as spreadsheetId which you used in URL). SheetId is basically numeric ID of your Tab in WorkSheet.</p>
<h3>Get SheetID</h3>
<p><strong>Request</strong></p><pre class="crayon-plain-tag">GET https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHtxxxxxxxxxxxxxx</pre><p>
<strong>Response</strong></p><pre class="crayon-plain-tag">{
  "spreadsheetId": "1tuGO3_-2JlSmyiHwX6bRFUWqqrXlt4BRoX8rCHrORJc",
  "properties": {
    "title": "Test.xlsx",
    "locale": "en",
    "autoRecalc": "ON_CHANGE",
    "timeZone": "America/Los_Angeles",
    "defaultFormat": {
      "backgroundColor": {
        "red": 1,
        "green": 1,
        "blue": 1
      },
      "padding": {
        "right": 3,
        "left": 3
      },
      "verticalAlignment": "BOTTOM",
      "wrapStrategy": "OVERFLOW_CELL",
      "textFormat": {
        "foregroundColor": {},
        "fontFamily": "Calibri",
        "fontSize": 11,
        "bold": false,
        "italic": false,
        "strikethrough": false,
        "underline": false
      }
    }
  },
  "sheets": [
    {
      "properties": {
        "sheetId": 1896331083,
        "title": "Sheet1",
        "index": 0,
        "sheetType": "GRID",
        "gridProperties": {
          "rowCount": 1000,
          "columnCount": 26,
          "rowGroupControlAfter": true,
          "columnGroupControlAfter": true
        }
      }
    }
  ],
  "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1tuGO3_-2JlSmyiHwX6bRFUWqqrXlt4BRoX8rCHrORJc/edit"
}</pre><p>
Notice that in above response we see <strong>&#8220;sheetId&#8221;: 1896331083</strong>. This ID we will use in the Update API to format Cells.</p>
<h3>Update Borders Example</h3>
<p>Here is the example of Google Sheet Formatting API <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#updatebordersrequest" target="_blank" rel="noopener">updateBorders Request</a></p><pre class="crayon-plain-tag">POST https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSxxxxlt4BRoX8rCHrORJc:batchUpdate
Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
  "requests": [
    {
      "updateBorders": {
        "range": {
          "sheetId": 1896331083,
          "startRowIndex": 0,
          "endRowIndex": 10,
          "startColumnIndex": 0,
          "endColumnIndex": 6
        },
        "top": {
          "style": "DASHED",
          "width": 1,
          "color": {
            "blue": 1.0
          },
        },
        "bottom": {
          "style": "DASHED",
          "width": 1,
          "color": {
            "blue": 1.0
          },
        },
        "innerHorizontal": {
          "style": "DASHED",
          "width": 1,
          "color": {
            "blue": 1.0
          },
        },
      }
    }
  ]
}</pre><p>
<strong>Response</strong></p><pre class="crayon-plain-tag">{
  "spreadsheetId": "1tuGO3_-2JlSmyiHwX6bRFUWqqrXlt4BRoX8rCHrORJc",
  "replies": [
    {}
  ]
}</pre><p>
&nbsp;</p>
<h3>Update Cell Font Style (Bold, Style, Color, Background)</h3>
<p>Now let&#8217;s look at how to use <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/request#RepeatCellRequest" target="_blank" rel="noopener">repeateCellRequest</a> to apply certain type of formatting to multiple cells. This may be color, font style, background color.</p><pre class="crayon-plain-tag">POST https://sheets.googleapis.com/v4/spreadsheets/1tuGO3xxxxxx4BRoX8rCHrORJc:batchUpdate
Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
  "requests": [
    {
      "repeatCell": {
        "range": {
          "sheetId": 1896331083,
          "startRowIndex": 0,
          "endRowIndex": 1
        },
        "cell": {
          "userEnteredFormat": {
            "backgroundColor": {
              "red": 0,
              "green": 0.5,
              "blue": 0.7,
              "alpha": 1.3
            },
            "textFormat": {
              "foregroundColor": {
                "red": 1
              },
              "bold": true,
              "italic": true,
              "strikethrough": true,
              "underline": true
            }
          }
        },
        "fields": "userEnteredFormat"
      }
    }
  ]
}</pre><p>
In above example we have applied <strong>textFormat</strong> and <strong>backgroundColor</strong> but you can use any of below sections.<br />
<div class="su-note"  style="border-color:#e5dd9d;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:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">
<span class="pun">{<br />
</span><span class="str">&#8220;numberFormat&#8221;<span class="pun">: </span><span class="pun">{</span><span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#NumberFormat">NumberFormat</a></code>)</span> <span class="pun">}</span><span class="pun">,</span><br />
&#8220;backgroundColor&#8221;<span class="pun">: </span><span class="pun">{</span> <span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#Color">Color</a></code>)</span> <span class="pun">}</span><span class="pun">,</span><br />
&#8220;borders&#8221;<span class="pun">: </span><span class="pun">{</span> <span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#Borders">Borders</a></code>)</span> <span class="pun">}</span><span class="pun">,</span><br />
&#8220;padding&#8221;<span class="pun">: </span><span class="pun">{</span> <span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#Padding">Padding</a></code>)</span> <span class="pun">}</span><span class="pun">,</span><br />
&#8220;horizontalAlignment&#8221;<span class="pun">: </span><span class="kwd">enum(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#HorizontalAlign">HorizontalAlign</a></code>)</span><span class="pun">,</span><br />
&#8220;verticalAlignment&#8221;<span class="pun">: </span><span class="kwd">enum(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#VerticalAlign">VerticalAlign</a></code>)</span><span class="pun">,</span><br />
&#8220;wrapStrategy&#8221;<span class="pun">: </span><span class="kwd">enum(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#WrapStrategy">WrapStrategy</a></code>)</span><span class="pun">,</span><br />
&#8220;textDirection&#8221;<span class="pun">: </span><span class="kwd">enum(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#TextDirection">TextDirection</a></code>)</span><span class="pun">,</span><br />
&#8220;textFormat&#8221;<span class="pun">: </span><span class="pun">{</span> <span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#TextFormat">TextFormat</a></code>)</span> <span class="pun">}</span><span class="pun">,<br />
</span> &#8220;hyperlinkDisplayType&#8221;<span class="pun">: </span><span class="kwd">enum(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#HyperlinkDisplayType">HyperlinkDisplayType</a></code>)</span><span class="pun">,</span><br />
&#8220;textRotation&#8221;<span class="pun">: </span><span class="pun">{</span> <span class="kwd">object(<code><a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#TextRotation">TextRotation</a></code>)</span> <span class="pun">}</span><br />
<span class="pun">}</span></span><br />
</div></div>
<h3>Set Currency Formatting</h3>
<p>Here is an example request to set currency formatting</p><pre class="crayon-plain-tag">POST https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6bRFUWqqrXlt4BRoX8rCHrORJc:batchUpdate
Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
  "requests": [
    {
      "repeatCell": {
        "range": {
          "sheetId": 1896331083,
          "startRowIndex": 1,
          "startColumnIndex": 4,
          "endColumnIndex": 5
        },
        "cell": {
          "userEnteredFormat": {
            "numberFormat": {
              "type": "CURRENCY",
              "pattern": "$#,##0.00"
            }
          }
        },
        "fields": "userEnteredFormat.numberFormat"
      }
    }
  ]
}</pre><p>
<h3>Set Cell Validation</h3>
<p>You can also set cell validation by calling following API call. This will restrict user&#8217;s ability to enter wrong data in certain cells.</p><pre class="crayon-plain-tag">POST https://sheets.googleapis.com/v4/spreadsheets/1tuGO3_-2JlSmyiHwX6bRFUWqqrXlt4BRoX8rCHrORJc:batchUpdate
Content-Type: application/json

&gt;&gt;&gt;&gt; BODY &lt;&lt;&lt;&lt;&lt;

{
  "requests": [
    {
      "setDataValidation": {
        "range": {
          "sheetId": 1896331083,
          "startRowIndex": 1,
          "startColumnIndex": 0,
          "endColumnIndex": 6
        },
        "rule": {
          "condition": {
            "type": "ONE_OF_LIST",
            "values": [
              {
                "userEnteredValue": "Red"
              },
              {
                "userEnteredValue": "Green"
              },
              {
                "userEnteredValue": "Yellow"
              }
            ]
          },
          "inputMessage": "Color must be Red, Yellow or Green",
          "strict": true,
          "showCustomUi": true
        }
      }
    }
  ]
}</pre><p>
&nbsp;</p>
<h2>Dynamically obtain File ID for Google Drive REST API call</h2>
<p>Once OAuth connection is defined you can now call any valid API from Google based on Permission you requested in OAuth Connection. OAuth connection takes care of renewing you Token and passing Authorization as per OAuth standard. All these protocol complexity is hidden from you.</p>
<p>First step to get data from Google SpreadSheet using REST API call is get fileId of the Google Drive File you want to read. The easiest way to know file ID is call following API. Below API call returns name, ID and other information about file(s). You can get only fileID and use that in Next Section to export Google SpreadSheet to CSV format.</p><pre class="crayon-plain-tag">https://www.googleapis.com/drive/v3/files</pre><p>
OR</p><pre class="crayon-plain-tag">https://www.googleapis.com/drive/v3/files/?q=name%3D'Customers'</pre><p>
<strong>NOTE:</strong> For more information about searching files in Google drive / getting list of files using search expression language <a href="https://developers.google.com/drive/v3/web/search-parameters#examples" target="_blank" rel="noopener">check this link.</a> Make sure expression is URL encoded (e.g. name=&#8217;Customers&#8217; should be passed as name%3D&#8217;Customers&#8217;)</p>
<p>Above API returns response as below. Notice the name and fileId. We will use <strong>fileId</strong> when calling export API in next section.</p><pre class="crayon-plain-tag">{
 "kind": "drive#fileList",
 "files": [
  {
   "kind": "drive#file",
   "id": "1lkMEgu0zm2Q-cnPeoNZp4hqeIuASxXSpsrxtDDV89tg",
   "name": "Customers",
   "mimeType": "application/vnd.google-apps.spreadsheet"
  },
  {
   "kind": "drive#file",
   "id": "0B6UyXr6ZlIFTc3RhcnRlcl9maWxl",
   "name": "How to get started with Drive",
   "mimeType": "application/pdf"
  }
 ]
}</pre><p>
If you want to automate retrieval of fileId from document name then perform the following steps.</p>
<ol>
<li>In the SSIS package Control flow. Drag and drop ZS REST API Task from SSIS toolbox</li>
<li>In the Request Access mode, select &#8220;URL from Connection&#8221; option</li>
<li>Select OAuth connection manager (Created in Section-2)</li>
<li>Enter URL as below (It will return any file name equals to Customers (%3D is encoded value for = sign)<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/drive/v3/files/?q=name%3D'Customers'</pre>
</li>
<li>Click Test (You will see file information)
<div id="attachment_848" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-call-google-drive-api-get-file-list.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-848" class="wp-image-848" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-call-google-drive-api-get-file-list.png" alt="Get Google Drive File List in SSIS - Call Google Drive API. Search file by name or expression " width="600" height="451" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-call-google-drive-api-get-file-list.png 776w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-call-google-drive-api-get-file-list-300x225.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-848" class="wp-caption-text">Get Google Drive File List in SSIS &#8211; Call Google Drive API to search file by name or expression</p></div></li>
<li>If you want to extract only fileID from full JSON then go to response tab</li>
<li>Select Format=JSON, Enter following JSONPath expression to extract only fileId from first record<br />
<pre class="crayon-plain-tag">$.files[0].id</pre>
</li>
<li>Check save response content, select SSIS variable where you want to save fileId as below. Now click Test to see preview of response. You will notice now only fileId will be returned from full JSON response.
<div id="attachment_849" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-get-google-drive-fileid-from-file-name-using-api-call.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-849" class="wp-image-849" src="//zappysys.com/blog/wp-content/uploads/2016/09/ssis-get-google-drive-fileid-from-file-name-using-api-call.png" alt="Get Google Drive fileid from file name using api call in SSIS" width="600" height="475" srcset="https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-get-google-drive-fileid-from-file-name-using-api-call.png 681w, https://zappysys.com/blog/wp-content/uploads/2016/09/ssis-get-google-drive-fileid-from-file-name-using-api-call-300x237.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-849" class="wp-caption-text">Get Google Drive fileid from file name using API call in SSIS</p></div></li>
<li>Click OK to save task</li>
</ol>
<h2>Conclusion</h2>
<p>Google Drive API and Google Sheets API provides a great way to automate file related functionality. However, to call Google API  you have to use SDK / coding approach (e.g. C#, Java, Python, Ruby). Luckily ZappySys <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> provides a great way to integrate any Google API call via simple drag and drop approach without coding. Try out yourself see how long it takes to call virtually any REST API.</p>
<p>The post <a href="https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/">How to read / write Google SpreadSheet using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
