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

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

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>API Integration Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/api-integration/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to read data from ElasticSearch using SSIS</title>
		<link>https://zappysys.com/blog/read-data-from-elasticsearch-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Fri, 20 Dec 2019 10:02:31 +0000</pubDate>
				<category><![CDATA[REST API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS REST API Task]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[elasticsearch]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[ssis]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=8573</guid>

					<description><![CDATA[<p>Introduction In our previous article, we see how to load data into Elastic Search using SSIS. Now let&#8217;s look at how to read data from ElasticSearch using SSIS and load response into SQL Server. Elasticsearch is a powerful engine that allows you to store, aggregate, and, most importantly, search data in a very analytical way. In this tutorial, you [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/read-data-from-elasticsearch-using-ssis/">How to read data from ElasticSearch 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/elasticsearch-connector/">API Connector for ElasticSearch</a> which makes it much simpler to <strong>Read/Write ElasticSearch 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 a learning curve with API then use a newer approach.</p>
<p>Please visit <a href="https://zappysys.com/api/integration-hub/">this page to see all</a> preconfigured ready-to-use API connectors that 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, and Informatica).</p>
</div></div>
<img decoding="async" class="alignleft wp-image-1406 size-thumbnail" src="https://zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180-150x150.png" alt="" width="150" height="150" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180.png 180w" sizes="(max-width: 150px) 100vw, 150px" /></p>
<p>In our previous article, we see how to <a href="https://zappysys.com/blog/load-data-from-sql-server-to-elasticsearch-using-ssis/" target="_blank" rel="noopener">load data into Elastic Search using SSIS</a>. Now let&#8217;s look at <strong>how to read data from ElasticSearch using SSIS</strong> and load response into SQL Server.</p>
<p><a href="https://www.elastic.co/" target="_blank" rel="noopener">Elasticsearch</a> is a powerful engine that allows you to store, aggregate, and, most importantly, search data in a very analytical way. In this tutorial, you will learn how to load <em>Elasticsearch </em>data to <em>SQL Server </em>with <a href="https://docs.microsoft.com/en-us/sql/integration-services/sql-server-integration-services" target="_blank" rel="noopener"><acronym title="SQL Server Integration Services">SSIS</acronym></a> (part of SQL Server) and <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys PowerPack</a>. We also see how to set the maximum result window of the index using the Rest API Task.</p>
<p>In a nutshell, this post will focus on how to Make Elasticsearch Search API call using SSIS.</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><span id="CallUPSREST_API_using_SSIS">Step-By-Step to Call Elasticsearch API call<span id="Step-By-Step_8211_CallSemantics3_REST_API_using_SSIS"> using SSIS</span></span></h2>
<h3>Read from Elasticsearch Search API call</h3>
<p>Let&#8217;s make the Elasticsearch <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html" target="_blank" rel="noopener">Search API</a> call using the JSON source to get all the records of the index with pagination.</p>
<ol>
<li>First of All, Drag and drop Data Flow Task from SSIS Toolbox and double click it to edit.
<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="" 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>From the SSIS toolbox drag and drop JSON Source on the data flow designer surface.
<div id="attachment_3766" style="width: 604px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3766" class="wp-image-3766 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png" alt="Drag and Drop JSON Source Component" width="594" height="268" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png 594w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin-300x135.png 300w" sizes="(max-width: 594px) 100vw, 594px" /></a><p id="caption-attachment-3766" class="wp-caption-text">Drag and Drop JSON Source Component</p></div></li>
<li>Double click JSON Source and enter the following URL as below to make Search API Call on the index.<br />
<pre class="crayon-plain-tag">http://{elasticsearch-site-url}/{index}/{index-type}/_search</pre>
</li>
<li>Now check Use credentials and <em>Select Connection</em> section press <pre class="crayon-plain-tag">&lt;New ZS-HTTP Connection&gt;</pre>.
<div id="attachment_1676" style="width: 972px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2015/08/ssis-json-source-rest-api-http-basic-authentication-pass-userid-password.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1676" class="size-full wp-image-1676" src="https://zappysys.com/blog/wp-content/uploads/2015/08/ssis-json-source-rest-api-http-basic-authentication-pass-userid-password.png" alt="SSIS JSON Source - Passing Basic Credentials (Supply UserID / Password) using HTTP Connection" width="962" height="757" srcset="https://zappysys.com/blog/wp-content/uploads/2015/08/ssis-json-source-rest-api-http-basic-authentication-pass-userid-password.png 962w, https://zappysys.com/blog/wp-content/uploads/2015/08/ssis-json-source-rest-api-http-basic-authentication-pass-userid-password-300x236.png 300w, https://zappysys.com/blog/wp-content/uploads/2015/08/ssis-json-source-rest-api-http-basic-authentication-pass-userid-password-768x604.png 768w" sizes="(max-width: 962px) 100vw, 962px" /></a><p id="caption-attachment-1676" class="wp-caption-text">SSIS JSON Source &#8211; Passing Basic Credentials (Supply UserID / Password) using HTTP Connection</p></div></li>
<li>Once the <em>HTTP Connection Manager</em> window opens configure the connection to your Elasticsearch instance:
<ul>
<li>Set <em>Web Url</em>, which points to your Elasticsearch instance.</li>
<li>Set <em>Credentials Type</em> to <pre class="crayon-plain-tag">Basic - UserID/Password</pre> (or other appropriate authentication methods).</li>
<li>Finally, set <em>User Name</em> and <em>Password:<br />
</em></p>
<div id="attachment_1419" style="width: 330px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1419" class="wp-image-1419 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png" alt="Configure SSIS HTTP Connection to connect to Elasticsearch" width="320" height="207" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png 320w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection-300x194.png 300w" sizes="(max-width: 320px) 100vw, 320px" /></a><p id="caption-attachment-1419" class="wp-caption-text">Configure SSIS <em>HTTP Connection</em> to connect to Elasticsearch</p></div></li>
</ul>
</li>
<li>Now, select method as POST and set for and size value in the body to get data using pagination. Set the content type as JSON (application/json).<br />
<pre class="crayon-plain-tag">{"from" : &lt;%page%&gt;, "size" : 100}</pre>
</li>
<li>Furthermore, go to the pagination tab and configure pagination like the below screenshot makes sure we need to enter increment size the same as given in body size value therefor 100.
<div id="attachment_8600" style="width: 747px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-pagination-post-data-mode.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8600" class="size-full wp-image-8600" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-pagination-post-data-mode.png" alt="Pagination Mode : POST data in body" width="737" height="720" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-pagination-post-data-mode.png 737w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-pagination-post-data-mode-300x293.png 300w" sizes="(max-width: 737px) 100vw, 737px" /></a><p id="caption-attachment-8600" class="wp-caption-text">Pagination Mode: POST data in the body</p></div></li>
<li>That&#8217;s it now select the desired filter and click on the Preview button.<a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-preview-elasticsearch-api.png"><img loading="lazy" decoding="async" class="aligncenter size-medium_large wp-image-8597" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-preview-elasticsearch-api-768x657.png" alt="" width="720" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-preview-elasticsearch-api-768x657.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-preview-elasticsearch-api-300x257.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-json-source-preview-elasticsearch-api.png 917w" sizes="(max-width: 720px) 100vw, 720px" /></a></li>
<li>That&#8217;s it we are ready to load the data in the SQL Server.</li>
</ol>
<h3>For more than 10000 rows</h3>
<p>When you try to get more than 100000 rows you will get the next error message</p><pre class="crayon-plain-tag">{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Result window is too large, from + size must be less than or equal to: [10000] but was [11000]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
            }
        ]
    },
    "status": 400
}</pre><p>
Here is how to configure your JSON Source to pull more than 10K rows using Scroll Method.</p>
<ol>
<li>In Settings Tab: In the Body and URL rather than Index name use <pre class="crayon-plain-tag">[$tag$]</pre></li>
<li>In the filter type: <pre class="crayon-plain-tag">$.hits.hits[*]._source</pre></li>
<li>Uncheck Include Parent
<div id="attachment_10804" style="width: 838px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/JSON-source-tag.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10804" class="size-full wp-image-10804" src="https://zappysys.com/blog/wp-content/uploads/2019/12/JSON-source-tag.png" alt="Elasticsearch JSON source general tab" width="828" height="808" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/JSON-source-tag.png 828w, https://zappysys.com/blog/wp-content/uploads/2019/12/JSON-source-tag-300x293.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/JSON-source-tag-768x749.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-10804" class="wp-caption-text">Elasticsearch example for more than 10000 rows</p></div></li>
<li>In Pagination Tab, Set Next Link as below <pre class="crayon-plain-tag">$._scroll_id</pre></li>
<li>Stop Indicator Attribute as below <pre class="crayon-plain-tag">$.hits.hits[0]._id</pre></li>
<li>Stop Indicator Value as <pre class="crayon-plain-tag">regex=^$</pre>
<div id="attachment_10805" style="width: 676px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-pagination-tab.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10805" class="size-full wp-image-10805" src="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-pagination-tab.png" alt="Elasticsearch JSON source pagination tab" width="666" height="299" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-pagination-tab.png 666w, https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-pagination-tab-300x135.png 300w" sizes="(max-width: 666px) 100vw, 666px" /></a><p id="caption-attachment-10805" class="wp-caption-text">Elasticsearch pagination tab configuration</p></div></li>
<li>In Advanced Pagination Tab, Check Has Different Page Info and Enable Page Token</li>
<li>Enter Page Place Holders as below (change YOUR_INDEX_NAME)<br />
<pre class="crayon-plain-tag">url=YOUR_INDEX_NAME/_search?scroll=10m|_search/scroll</pre></li>
<li>First Page Body as below &#8211; Change query as needed else keep it match all to fetch all rows from Index<br />
<pre class="crayon-plain-tag">{ "size":1000, "query": { "match_all": { }  } }</pre></li>
<li>Next Page Body as below <pre class="crayon-plain-tag">{  "scroll": "5m", "scroll_id": "[$pagetoken$]" }</pre>
<div id="attachment_10806" style="width: 676px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-advanced-pagination-tab.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10806" class="size-full wp-image-10806" src="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-advanced-pagination-tab.png" alt="Elasticsearch JSON source advanced pagination tab" width="666" height="299" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-advanced-pagination-tab.png 666w, https://zappysys.com/blog/wp-content/uploads/2019/12/Elasticsearch-advanced-pagination-tab-300x135.png 300w" sizes="(max-width: 666px) 100vw, 666px" /></a><p id="caption-attachment-10806" class="wp-caption-text">Configuration for Elasticsearch advanced pagination tab</p></div></li>
</ol>
<h3>Loading Elasticsearch API data into SQL Server / Other Target</h3>
<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>
<h3>Enable Deep Pagination Setting</h3>
<p>By default index, the maximum result window size is 10,000 means you can paginate upto 10000 rows. If you ever want to get more than 10000 result then you have to perform the following steps to change default setting from 10000 to 500000 (that&#8217;s max).</p>
<p>We need to send PUT request to below URL:</p><pre class="crayon-plain-tag">http://{elasticsearch-site-url}/{your-index}/_settings</pre><p>
Need to pass below body as I am setting max result window size value as 500000.</p><pre class="crayon-plain-tag">{ "index" : { "max_result_window" : 500000 } }</pre><p>
And set content-type as JSON (application/json) and click on Test Request/Response and it will make the API call and set the max window size.</p>
<div id="attachment_8577" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8577" class="wp-image-8577 size-medium_large" src="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call-768x419.png" alt="Rest API Task PUT Call" width="720" height="393" srcset="https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call-768x419.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call-300x164.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call-1024x559.png 1024w, https://zappysys.com/blog/wp-content/uploads/2019/12/ssis-rest-api-task-elasticsearch-put-setting-call.png 1221w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-8577" class="wp-caption-text">Rest API Task PUT Call</p></div>
<p>That&#8217;s it we have successfully made the call to set the maximum result window size of the index.</p>
<h3></h3>
<h2>Common Errors</h2>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2>Deployment to Production</h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<h2><span id="Conclusion">Conclusion</span></h2>
<p>After all, we saw you How to Make Elasticsearch Search API call using SSIS JSON Source and load response into SQL Server. In this article, we have seen that how to make a setting call to set the maximum result window of the index. 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>
<h2><span id="References">References</span></h2>
<p>Finally, you can use the following links for more information:</p>
<ul>
<li>Help File: <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/json-source.htm" target="_blank" rel="noopener">JSON Source(REST API or File)</a></li>
<li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html" target="_blank" rel="noopener">Elasticsearch Search APIs </a></li>
</ul>
<p>The post <a href="https://zappysys.com/blog/read-data-from-elasticsearch-using-ssis/">How to read data from ElasticSearch using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to read/load data in Xero using SSIS</title>
		<link>https://zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 25 Jul 2017 03:02:24 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[oauth1]]></category>
		<category><![CDATA[OAuth2.0]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis json source]]></category>
		<category><![CDATA[ssis oauth connection]]></category>
		<category><![CDATA[X509]]></category>
		<category><![CDATA[Xero]]></category>
		<category><![CDATA[Xero Api]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1602</guid>

					<description><![CDATA[<p>Introduction Xero is well known Cloud based Accounting Software. In this post you will learn how to implement Xero API Integration with SQL Server or any other RDBMS (e.g. Oracle, MySQL, Postgresql) using SSIS in few clicks. We will use SSIS JSON Source to Read data from Xero and Load into SQL Server / other [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/">How to read/load data in Xero 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="//zappysys.com/blog/wp-content/uploads/2017/07/xero-integration.png"><img loading="lazy" decoding="async" class="alignleft wp-image-1621" src="//zappysys.com/blog/wp-content/uploads/2017/07/xero-integration.png" alt="" width="120" height="120" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/xero-integration.png 375w, https://zappysys.com/blog/wp-content/uploads/2017/07/xero-integration-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/07/xero-integration-300x300.png 300w" sizes="(max-width: 120px) 100vw, 120px" /></a>Xero is well known Cloud based Accounting Software. In this post you will learn how to implement <a href="https://developer.xero.com/documentation/getting-started/getting-started-guide" target="_blank" rel="noopener">Xero API</a> Integration with SQL Server or any other RDBMS (e.g. Oracle, MySQL, Postgresql) using <strong>SSIS</strong> in few clicks. We will use <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">SSIS JSON Source</a> to <strong>Read data from Xero</strong> and Load into SQL Server / other target (Using OAuth Connection). We will also discuss reverse scenario to <strong>Write data to Xero</strong> (API POST for Insert or Update in Xero) using <a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">SSIS Web API Destination</a> and <a href="//zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">SSIS JSON Generator Transform</a></p>
<h2></h2>
<h2><span id="Prerequisites">Prerequisites</span></h2>
<p>Before we look into Step-By-Step section to extract and load data from <strong>Xero to SQL Server</strong> let’s make sure you met following requirements.</p>
<ol>
<li>SSIS designer installed. Sometimes it is referred as BIDS or SSDT (<a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" target="_blank" rel="noopener">download it from Microsoft site</a>).</li>
<li>Basic knowledge of SSIS package development using <em>Microsoft SQL Server Integration Services</em>.</li>
<li><a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener"><em>ZappySys SSIS PowerPack</em> installed</a>. Click on the link to download FREE trial.</li>
<li>You have basic familiarity with REST API concepts and Xero API.</li>
</ol>
<h2>Concepts of Xero REST API</h2>
<h3>API Authorization</h3>
<p>Before you can access Xero API you must register account and App. There are 3 types of Apps to access Xero API.</p>
<ol>
<li>Private App (X509 Certificate used to sign requests)</li>
<li>Public App (Use 3-legged OAuth. Token expires in 30 mins and then you have to authorize again from UI)</li>
<li>Partner App (Use 3-legged OAuth. Token expires in 30 mins.. but refresh token supported to get new token for unlimited times without Authorization via Login UI)</li>
<li><a href="https://developer.xero.com/documentation/oauth2/auth-flow" target="_blank" rel="noopener">OAuth2.0 Authentication (Recommended) </a></li>
</ol>
<p>In this article we will use <a href="https://developer.xero.com/documentation/auth-and-limits/private-applications" target="_blank" rel="noopener">Private App</a> to access your company data in Xero.</p>
<h3>Data formats</h3>
<p>Xero API supports Xml and JSON both formats over the same URL (endpoints). If you want data in JSON format then you have to pass following Header (else data in Xml format will be returned). If you are using <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">SSIS JSON Source</a> then make sure following header is added. For <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">SSIS XML Source</a> no need to add this header.</p><pre class="crayon-plain-tag">Accept : application/json</pre><p>
<h2>Step-By-Step : Xero API Integration in SSIS</h2>
<p>Now lets look at steps needed to fetch data from Xero and load into SQL Server.</p>
<h3><span id="Configure_OAuth_Connection_for_Google_BigQuery_API">Configure OAuth2.0 Connection for Xero API (Recommended)</span></h3>
<p>So let&#8217;s how to create the Xero OAuth2.0 connection. For more on OAuth2.0 refer to <a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">this article</a>.</p>
<ol>
<li>Right-click inside the Connection Managers area again and click “New Connection…”</li>
<li>From the connection type list select “ZS-OAUTH” connection type.
<div id="attachment_1569" style="width: 687px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1569" class="wp-image-1569 size-full" src="https://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>Select<em> OAuth Provider </em>which Custom, enter the CleintID and Secret and set the URLs as below and desired <a href="https://developer.xero.com/documentation/oauth2/scopes" target="_blank" rel="noopener">scopes</a> that are required for the API Call.<br />
Auth URL:<br />
<pre class="crayon-plain-tag">https://login.xero.com/identity/connect/authorize</pre>
Token URL:<br />
<pre class="crayon-plain-tag">https://identity.xero.com/connect/token</pre>
Scopes: Add your desired scopes based on your API call requirements.<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;">Note: To get a refresh token, you must request the offline_access scope. A refresh token allows you to refresh your access token and maintain an offline connection.<br />
<strong>offline_access</strong></p>
<p><a href="https://developer.xero.com/documentation/guides/oauth2/scopes/#offline-access" target="_blank" rel="noopener">https://developer.xero.com/documentation/guides/oauth2/scopes/#offline-access</a></div></div>
<div id="attachment_8858" style="width: 681px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-configuration.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8858" class="wp-image-8858 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-configuration.png" alt="OAuth2.0 Connection" width="671" height="695" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-configuration.png 671w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-configuration-290x300.png 290w" sizes="(max-width: 671px) 100vw, 671px" /></a><p id="caption-attachment-8858" class="wp-caption-text">OAuth2.0 Connection</p></div></li>
<li> Now go to the Advanced tab and set the redirect URL as below and also you need to set the same URL in the Xero API App.<br />
<pre class="crayon-plain-tag">https://zappysys.com/oauth2</pre>
<div id="attachment_1345" style="width: 581px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-oauth-setting-redirect-url1.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1345" class="wp-image-1345 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-oauth-setting-redirect-url1.png" alt="" width="571" height="123" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-oauth-setting-redirect-url1.png 571w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-oauth-setting-redirect-url1-300x65.png 300w" sizes="(max-width: 571px) 100vw, 571px" /></a><p id="caption-attachment-1345" class="wp-caption-text">Set Callback/Return Url in OAuth Connection</p></div></li>
<li>Now Click on the Generate Token Button and logged in with Xero username and password and grant permission.</li>
<li>That&#8217;s it your token is generated. If you got the blank Screen like this after following all the steps. Close that window.
<div id="attachment_8859" style="width: 671px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-blank-screen.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8859" class="wp-image-8859 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-blank-screen.png" alt="OAuth2.0 connection : Blank Window at last" width="661" height="653" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-blank-screen.png 661w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-oauth2.0-connection-blank-screen-300x296.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-8859" class="wp-caption-text">OAuth2.0 connection : Blank Window at last</p></div></li>
<li>And it will ask you to use the Different Method to generate the Token using system default browser <strong>click on YES</strong>.
<div id="attachment_8860" style="width: 671px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-default-browser-to-generate-toekn.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8860" class="size-full wp-image-8860" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-default-browser-to-generate-toekn.png" alt="Different Method to generate the Token using system default browser" width="661" height="653" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-default-browser-to-generate-toekn.png 661w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-default-browser-to-generate-toekn-300x296.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-8860" class="wp-caption-text">Different Method to generate the Token using system default browser</p></div></li>
<li>It will open the URL in the browser there you need to log in and grant the permission.</li>
<li>After that, you will able to view the access token in the browser. you can copy from there also.
<div id="attachment_8861" style="width: 738px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-default-browser-generated-token.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8861" class="wp-image-8861 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-default-browser-generated-token.png" alt="Generated Token" width="728" height="347" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-default-browser-generated-token.png 728w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-default-browser-generated-token-300x143.png 300w" sizes="(max-width: 728px) 100vw, 728px" /></a><p id="caption-attachment-8861" class="wp-caption-text">Generated Token</p></div></li>
<li>At the last, it will again focus on the connection and there it will ask you to save the token if you want to store it. if not then you can manually copy and paste that token.
<div id="attachment_8862" style="width: 671px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-popup-to-store-token.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8862" class="wp-image-8862 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-popup-to-store-token.png" alt="OAuth Connection : Store the Tokens" width="661" height="653" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-popup-to-store-token.png 661w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-popup-to-store-token-300x296.png 300w" sizes="(max-width: 661px) 100vw, 661px" /></a><p id="caption-attachment-8862" class="wp-caption-text">OAuth Connection : Store the Tokens</p></div></li>
<li>That&#8217;s it now click on the Test Connection button to test it.
<div id="attachment_6415" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/01/odbc-quickbooks-oauth-test.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6415" class="size-medium_large wp-image-6415" src="https://zappysys.com/blog/wp-content/uploads/2019/01/odbc-quickbooks-oauth-test-768x735.png" alt="" width="720" height="689" srcset="https://zappysys.com/blog/wp-content/uploads/2019/01/odbc-quickbooks-oauth-test-768x735.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/01/odbc-quickbooks-oauth-test-300x287.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/01/odbc-quickbooks-oauth-test.png 771w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-6415" class="wp-caption-text">Generate Token and Test Connection</p></div></li>
</ol>
<h3>Register OAuth App Private for Xero (Private App) OAuth Connection (Depreciated)</h3>
<p>Here is how to configure Xero to use Private App (click on below link).</p>
<p><a href="https://developer.xero.com/documentation/auth-and-limits/private-applications" target="_blank" rel="noopener">https://developer.xero.com/documentation/auth-and-limits/private-applications</a></p>
<p>In the above link during <a href="https://developer.xero.com/documentation/api-guides/create-publicprivate-key" target="_blank" rel="noopener">these steps</a> <strong>openssl</strong> command may throw error about <strong>openssl.cnf is missing</strong> or cannot load. If you face such error then don&#8217;t worry just refer to following workaround.</p>
<p><a href="https://stackoverflow.com/questions/14459078/unable-to-load-config-info-from-usr-local-ssl-openssl-cnf" target="_blank" rel="noopener">https://stackoverflow.com/questions/14459078/unable-to-load-config-info-from-usr-local-ssl-openssl-cnf</a></p>
<p>Basically you can either supply config file path in each command OR set path by issuing SET command before any other command. See below examples (Assuming you installed OpenSSL to c:\OpenSSL-Win64 folder)</p><pre class="crayon-plain-tag">c:\OpenSSL-Win64&amp;gt;openssl req -x509 -config &quot;C:\OpenSSL-Win64\bin\openssl.cnf&quot;</pre><p>
&#8212; OR &#8212;  type before command before any other openssl commands</p><pre class="crayon-plain-tag">c:\OpenSSL-Win64&amp;gt;set OPENSSL_CONF=c:\OpenSSL-Win64\bin\openssl.cnf

c:\OpenSSL-Win64&amp;gt;openssl req -x509 -config &quot;C:\OpenSSL-Win64\bin\openssl.cnf&quot;</pre><p>
Once you generate public key, private key and, pfx file we are ready to <strong>call Xero API in SSIS</strong></p>
<h4><span id="Configure_OAuth_Connection_for_Google_BigQuery_API">Configure Xero (Private App) OAuth Connection</span></h4>
<p>Once you generate certificate using openssl and register Private App for Xero we are ready to move to SSIS piece. Lets see how to do that.</p>
<ol>
<li>Open Visual Studio</li>
<li>Open existing SSIS Project or create new using File &gt; New &gt; Project &gt; Choose &#8220;Integration Services Project&#8221; Type under Business Intelligence template category</li>
<li>Open Package</li>
<li>Right click inside Connection Managers area and click “New Connection…”</li>
<li>From the connection type list select “ZS-OAUTH” connection type.
<div id="attachment_1569" class="wp-caption alignnone">
<p><a href="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png"><img loading="lazy" decoding="async" class="size-full wp-image-1569" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?resize=677%2C220" sizes="(max-width: 677px) 100vw, 677px" srcset="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?w=677 677w, https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?resize=300%2C97 300w" alt="Create new SSIS OAuth API Connection Manager" width="643" height="209" data-attachment-id="1569" data-permalink="https://zappysys.com/blog/get-data-google-bigquery-using-ssis/ssis-oauth-create-new-connection/#main" data-orig-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?fit=677%2C220&amp;ssl=1" data-orig-size="677,220" 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-oauth-create-new-connection" data-image-description="&lt;p&gt;Create new SSIS OAuth API Connection Manager&lt;/p&gt; " data-medium-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?fit=300%2C97&amp;ssl=1" data-large-file="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-create-new-connection.png?fit=677%2C220&amp;ssl=1" /></a></p>
<p class="wp-caption-text">Create new SSIS OAuth API Connection Manager</p>
</div>
</li>
<li>On the connection select “Xero (Private App)” from Service Provider Dropdown</li>
<li>Enter Client ID (Obtain this from <a href="https://app.xero.com/Application/" target="_blank" rel="noopener">App created</a> in Previous section) App Selection leave “Use Default OAuth App” 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 select “Use Custom OAuth App” Option</li>
<li>Enter some fake value in Client Secret (not needed when you use Private App). Secret will come from certificate file like below.
<div id="attachment_1612" style="width: 685px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-for-xero-private-app-x509-certificate.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1612" class="size-full wp-image-1612" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-for-xero-private-app-x509-certificate.png" alt="SSIS OAuth Connection - Configure Xero API Connectivity using Private App (Certificate File Approach)" width="675" height="512" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-for-xero-private-app-x509-certificate.png 675w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-connection-for-xero-private-app-x509-certificate-300x228.png 300w" sizes="(max-width: 675px) 100vw, 675px" /></a><p id="caption-attachment-1612" class="wp-caption-text">SSIS OAuth Connection &#8211; Configure Xero API Connectivity using Private App (Certificate File Approach)</p></div></li>
<li>Now go to Certificate tab and Check Use Certificate Enter, Enter certificate location and password like below.
<div id="attachment_1611" style="width: 685px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-xero-x509-certificate-public-private-key-example-pfx-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1611" class="size-full wp-image-1611" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-xero-x509-certificate-public-private-key-example-pfx-file.png" alt="SSIS OAuth Connection - Configure X509 Certificate File Option for Xero Private App (Select PFX file)" width="675" height="512" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-xero-x509-certificate-public-private-key-example-pfx-file.png 675w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-oauth-xero-x509-certificate-public-private-key-example-pfx-file-300x228.png 300w" sizes="(max-width: 675px) 100vw, 675px" /></a><p id="caption-attachment-1611" class="wp-caption-text">SSIS OAuth Connection &#8211; Configure X509 Certificate File Option for Xero Private App (Select PFX file)</p></div></li>
<li>Click OK to save OAuth connection manager</li>
</ol>
<p>So <strong>in the next section</strong> from the upper connections, <strong>we need to use any of the one connection only</strong> for Xero API now let&#8217;s try to read data from Xero using <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">SSIS JSON Source</a>.</p>
<p><strong>Xero recently added OAuth 2.0 support so that now recommended way to use as Connection.</strong></p>
<h3>Configure JSON / REST API Source &#8211; Read data from Xero</h3>
<p>Now let&#8217;s look at how to configure SSIS JSON Source to read data from Xero API</p>
<ol>
<li>In the control flow ssis toolbox Drag and drop data flow task</li>
<li>Double click Data flow</li>
<li>Drag ZS JSON Source (REST API or File) from SSIS Toolbox and drop on Data flow designer</li>
<li>Double click <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">ZS JSON Source</a> to configure it.</li>
<li>Set the following properties
<ol>
<li>Enter URL<br />
<pre class="crayon-plain-tag">https://api.xero.com/api.xro/2.0/Invoices</pre>
</li>
<li>Check Use Credentials and select OAuth connection we created in the previous section</li>
<li>For Headers grid. Click on <strong>Raw Edit</strong> button and remove enter following (remove default headers)<br />
<pre class="crayon-plain-tag">Accept: application/json</pre>
</li>
<li>Click on Select filter and select an array node as below to generate filter expression (e.g. $.Invoices[*] )</li>
</ol>
</li>
</ol>
<div id="attachment_1615" style="width: 1120px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1615" class="size-full wp-image-1615" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source.png" alt="Configure SSIS JSON /REST API Source - Read Xero Invoices" width="1110" height="714" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source.png 1110w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source-300x193.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source-768x494.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-read-invoices-using-json-rest-api-source-1024x659.png 1024w" sizes="(max-width: 1110px) 100vw, 1110px" /></a><p id="caption-attachment-1615" class="wp-caption-text">Configure SSIS JSON /REST API Source &#8211; Read Xero Invoices</p></div>
<p>Also, add following header in case of multiple tenants are being used in XERO environment &#8211;</p><pre class="crayon-plain-tag">xero-tenant-id: &lt;TENANT ID FROM XERO&gt;</pre><p>
<h3>Configure Xero REST API Pagination in SSIS JSON Source</h3>
<p>By default, Xero may not send you all records and you may have to setup pagination to read more data after the first response.</p>
<p>For example, you like to read LineItems from Invoices. For that make sure you use below URL and include page=1 to start with. If you do not include page=1 then Line items are not returned (Yes its ODD but clearly <a href="https://developer.xero.com/documentation/api/invoices" target="_blank" rel="noopener">documented here</a>).</p>
<ol>
<li>Enter URL as<br />
<pre class="crayon-plain-tag">https://api.xero.com/api.xro/2.0/Invoices?page=1</pre>
</li>
<li>Select Filter as <pre class="crayon-plain-tag">$.Invoices[*].LineItems[*]</pre></li>
<li>Go to Pagination tab</li>
<li>Select Pagination by URL Parameter</li>
<li>Enter <strong>page</strong> as pagination parameter name like below
<div id="attachment_457" style="width: 843px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-looping-url-parameter-mode.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-457" class="size-full wp-image-457" src="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-looping-url-parameter-mode.png" alt="REST API Looping/Pagination via URL Page Number Parameter (Loop until last page detected)" width="833" height="585" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-looping-url-parameter-mode.png 833w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-looping-url-parameter-mode-300x211.png 300w" sizes="(max-width: 833px) 100vw, 833px" /></a><p id="caption-attachment-457" class="wp-caption-text">REST API Looping/Pagination via URL Page Number Parameter (Loop until last page detected)</p></div></li>
<li>Click OK to save</li>
</ol>
<p>Now when you run package you will see all LineItems for each Invoice will be returned.</p>
<h3>Loading Xero data to SQL Server</h3>
<p>Now last step is loading Xero data to SQL Server. For example purpose we will load data into SQL Server but you can load into any Target (e.g. Flat file, Oracle, Excel) using Microsoft or ZappySys Destination connectors</p>
<p>To load Xero data into SQL Server perform following steps</p>
<ol>
<li>Drag OLEDB destination on Data Flow surface</li>
<li>Connect ZS JSON Source to Destination</li>
<li>On OLEDB destination select / create new SQL Connection and then Click &#8220;New Table&#8221;</li>
<li>Click on Mappings tab and click OK to save</li>
<li>Execute Package</li>
</ol>
<div id="attachment_1617" style="width: 792px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1617" class="size-full wp-image-1617" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png" alt="Configure SSIS OLEDB Destination - Loading Xero Data into SQL Server Table" width="782" height="593" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load.png 782w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load-300x227.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-to-sql-server-data-load-768x582.png 768w" sizes="(max-width: 782px) 100vw, 782px" /></a><p id="caption-attachment-1617" class="wp-caption-text">Configure SSIS OLEDB Destination &#8211; Loading Xero Data into SQL Server Table</p></div>
<div id="attachment_1618" style="width: 744px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1618" class="size-full wp-image-1618" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png" alt="Xero to SQL Server Column Mappings for OLEDB Destination" width="734" height="543" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings.png 734w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-sql-server-load-mappings-300x222.png 300w" sizes="(max-width: 734px) 100vw, 734px" /></a><p id="caption-attachment-1618" class="wp-caption-text">Xero to SQL Server Column Mappings for OLEDB Destination</p></div>
<div id="attachment_1619" style="width: 293px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1619" class="size-full wp-image-1619" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png" alt="Loading Xero data to SQL Server in SSIS" width="283" height="391" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server.png 283w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-loading-data-from-xero-to-sql-server-217x300.png 217w" sizes="(max-width: 283px) 100vw, 283px" /></a><p id="caption-attachment-1619" class="wp-caption-text">Loading Xero data to SQL Server in SSIS</p></div>
<h2>POST data to Xero (Insert or Update)</h2>
<p>So far we have seen how to read data from Xero. Now let&#8217;s look at how to write data to Xero.</p>
<p>There are two ways you can achieve this.</p>
<ol>
<li>Use <a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> in Data Flow</li>
<li>Use <a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a> in Control Flow</li>
</ol>
<p>Read this article to learn more about <a href="//zappysys.com/blog/http-post-in-ssis-send-data-to-web-api-url-json-xml/" target="_blank" rel="noopener">API POST using SSIS</a></p>
<h3>Using SSIS Web API Task (Write data from SQL Server to Xero)</h3>
<h3><img decoding="async" src="https://i0.wp.com/zappysys.com/onlinehelp/ssis-powerpack/scr/images/web-api-destination/ssis-web-api-destination-post-json-to-rest-api-url.png?resize=503%2C403" alt="SSIS Web API Destination - POST JSON to REST API Endpoint, Create / Update records" /></h3>
<h3>Using REST API Task to POST data to Xero</h3>
<p>If you have JSON/XML data already prepared and if you like to POST it to Xero API then REST API Task would be easy to use.</p>
<p>REST API Task Body can be direct string, variable (e.g. {{User::varSomeData}} or <a href="https://zappysys.com/blog/rest-api-file-upload-using-ssis-multi-part-post/" target="_blank" rel="noopener">Body can come from File </a></p>
<div id="attachment_1616" style="width: 872px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1616" class="size-full wp-image-1616" src="//zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png" alt="SSIS REST API Task - POST data to Xero (Create contacts)" width="862" height="602" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png 862w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example-300x210.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example-768x536.png 768w" sizes="(max-width: 862px) 100vw, 862px" /></a><p id="caption-attachment-1616" class="wp-caption-text">SSIS REST API Task &#8211; POST data to Xero (Create contacts)</p></div>
<h2>Read data from Xero Report API</h2>
<p>In previous examples we saw how to read data from various Xero API endpoints but now lets look at how to call <a href="https://developer.xero.com/documentation/api/reports" target="_blank" rel="noopener">Xero Report API</a>. For example if you like to extract data displayed in below then you can extract it in Xml or JSON format. Below report is in HTML format but we will show you how to get similar information in JSON format and load into SQL Server Table.</p>
<div style="width: 460px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full" src="https://www.xero.com/blog/wp-content/uploads//2008/10/pandlreport.png" alt="Xero Report Example - View Profit and Loss Report in Xero Portal" width="450" height="257" /><p class="wp-caption-text">Xero Report Example &#8211; View Profit and Loss Report in Xero Portal</p></div>
<p>To extract above information you can call below API Endpoint (e.g. <a href="https://developer.xero.com/documentation/api/reports#ProfitAndLoss" target="_blank" rel="noopener">Profit &amp; Loss Report</a>)</p><pre class="crayon-plain-tag">GET 
https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss?fromDate=2017-02-01&amp;toDate=2017-02-28</pre><p>
You can use Variables to make above URL dynamic in JSON Source as below</p><pre class="crayon-plain-tag">https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss?fromDate={{User::StartDate,yyyy-MM-dd}}&amp;toDate={{User::EndDate,yyyy-MM-dd}}</pre><p>
Each report has its own API URL so make sure you refer to the connect URL for calling different report.</p>
<p>Here is sample response from API</p><pre class="crayon-plain-tag">{
  "Reports": [
    {
      "ReportID": "ProfitAndLoss",
      "ReportName": "Profit and Loss",
      "ReportType": "ProfitAndLoss",
      "ReportTitles": [
        "Profit &amp; Loss",
        "Demo Company (AU)",
        "1 February 2018 to 28 February 2018"
      ],
      "ReportDate": "25 February 2018",
      "UpdatedDateUTC": "\/Date(1519593468971)\/",
      "Rows": [
        {
          "RowType": "Header",
          "Cells": [
            { "Value": "" },
            { "Value": "28 Feb 18" },
            { "Value": "28 Jan 18" }
          ]
        },
        {
          "RowType": "Section",
          "Title": " Income",
          "Rows": [
            {
              "RowType": "Row",
              "Cells": [
                {
                  "Value": "Sales",
                  "Attributes": [
                    {
                      "Value": "e2bacdc6-2006-43c2-a5da-3c0e5f43b452",
                      "Id": "account"
                    }
                  ]
                },{
                  "Value": "9220.05",
                  "Attributes": [
                    {
                      "Value": "e2bacdc6-2006-43c2-a5da-3c0e5f43b452",
                      "Id": "account"
                    }
                  ]
                },{
                  "Value": "5120.05",
                  "Attributes": [
                    {
                      "Value": "e2bacdc6-2006-43c2-a5da-3c0e5f43b452",
                      "Id": "account"
                    }
                  ]
                }
              ]
            },
            {
              "RowType": "SummaryRow",
              "Cells": [
                { "Value": "Total Income" },
                { "Value": "9220.05" },
                { "Value": "1250.09" }
              ]
            }
          ]
        },{
          "RowType": "Section",
          "Rows": [
            {
              "RowType": "Row",
              "Cells": [
                { "Value": "NET PROFIT" },
                { "Value": "-6250.09" },
                { "Value": "-7250.09" }
              ]
            }
          ]
        }
      ]
    }
  ]
}</pre><p>
&nbsp;</p>
<p>Now lets look at steps to configure JSON Source to extract your Xero Report Data.</p>
<ol>
<li>Drag new JSON Source from SSIS Toolbox</li>
<li>Double click JSON Source to configure it</li>
<li>In the Path / Web URL, enter API Report URL to call desired Report Start / End Date or any other expected Parameter by report (<strong>Refer to API Documentation</strong>). For our example we will enter below URL<br />
<pre class="crayon-plain-tag">https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss?fromDate=2017-02-01&amp;toDate=2017-02-28</pre>
</li>
<li>Check <strong>Use Credentials</strong> and Select Connection we created in the Previous Section</li>
<li>In the Filter enter <pre class="crayon-plain-tag">$.Reports[*].Rows[*].Rows[*]</pre></li>
<li>Now go to 2D Array Transform Tab and configure like below. If your UI varies then use Properties window to edit property manually.<br />
Basically you need to edit<br />
<strong>Transformation Type:</strong> <pre class="crayon-plain-tag">2-dimensional array</pre>
<strong>Column Name Filter:</strong> <pre class="crayon-plain-tag">$.Reports[0].Rows[*].Cells[*].Value</pre>
<strong>Row Values Filter:</strong> <pre class="crayon-plain-tag">$.Cells[*].Value</pre></li>
<li>Now Click Preview Data. If you get error Column &#8221; does not belong to table nosqldata. Then most likely you using old version with Known Issue (i.e. v2.9.7.10822 or older). Get latest version for fix. For workaround of this issue you must follow next section to specify columns manually. Columns must match count.</li>
</ol>
<p>Here is how it will look like.</p>
<div id="attachment_8037" style="width: 680px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-filter-options-extract-report.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8037" class="size-full wp-image-8037" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-filter-options-extract-report.png" alt="Configure Transform Options for Xero Report API (Dynamic Column Title)" width="670" height="166" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-filter-options-extract-report.png 670w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-api-filter-options-extract-report-300x74.png 300w" sizes="(max-width: 670px) 100vw, 670px" /></a><p id="caption-attachment-8037" class="wp-caption-text">Configure Transform Options for Xero Report API (Dynamic Column Title)</p></div>
<div id="attachment_8039" style="width: 842px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-json-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8039" class="size-full wp-image-8039" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-json-source.png" alt="Read from Xero Report API using JSON Source in SSIS (Dynamic Columns Example)" width="832" height="526" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-json-source.png 832w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-json-source-300x190.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-json-source-768x486.png 768w" sizes="(max-width: 832px) 100vw, 832px" /></a><p id="caption-attachment-8039" class="wp-caption-text">Read from Xero Report API using JSON Source in SSIS (Dynamic Columns Example)</p></div>
<h3>Fixing Dynamic Columns Problem in for Xero Report API</h3>
<p>Now let&#8217;s look at one common scenario which you have to think. SSIS data flow has fixed metadata so if your Report is generating Dynamic Columns each time based on Date Range then it will be trouble for you because all your columns may come as null if initial date range changes.</p>
<p>To address this issue you have to use Static Column Names as below.</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: You must enter exact same number of columns returned in the Header Row section or more. If you enter less number of columns then you will get error. For example in previous sample report screen we have following 6 Columns. Portal HTML report page shows YTD as extra column but API may not return this column so you will have to count it as 5 columns in below example. Best thing is enter 13 or more columns (typically covers 12 months data). If report doesn&#8217;t return all columns then you will get some as NULL but its ok because it will not fail.</div></div>
<pre class="crayon-plain-tag">Account (or sometimes blank) | Oct 08 | Sep 08 | Aug 08 | Jul 08 | YTD</pre>
In above case you have to enable following properties. (Below Screenshot has Col1,Col2&#8230;.. Col13  but you can enter less number of columns based on above logic of column count).</p>
<p><strong>NOTE:</strong> Use <a href="https://zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to obtain Raw JSON and review First Row which contains Number of columns<br />
For example if your API return some thing like below then you can use <strong>5 columns</strong> (<strong>one Blank header + 4 Months</strong>)</p><pre class="crayon-plain-tag">"Rows": [
        {
          "RowType": "Header",
          "Cells": [
            { "Value": "" },
            { "Value": "28 Feb 18" }
            { "Value": "28 Mar 18" }
            { "Value": "28 Apr 18" }
            { "Value": "28 May 18" }
          ]
        },</pre><p>
Once we know how many columns we should expect from API response, we can perform following steps. We will now configure our JSON Source component to use Static Columns.</p>
<ol>
<li>Drag new JSON Source from SSIS Toolbox</li>
<li>Right click JSON Source &gt; Click on Properties (You can do below using UI too but in old version no option for that &#8211; See below this section)</li>
<li>Enter following values for property
<ol>
<li><strong>Filter:</strong> <pre class="crayon-plain-tag">$.Reports[*].Rows[*].Rows[*]</pre></li>
<li><strong>ArrayTransformationType:</strong> <pre class="crayon-plain-tag">TransformComplexTwoDimensionalArray</pre></li>
<li><strong>ArrayTransCustomColumns:</strong> <pre class="crayon-plain-tag">Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13</pre>    <strong>(Assuming you have 12 months to compare)</strong></li>
<li><strong>ArrayEnableCustomColumn:</strong> <pre class="crayon-plain-tag">True</pre></li>
<li><strong>ArrayTransRowValueFilter:</strong> <pre class="crayon-plain-tag">$.Cells[*].Value</pre></li>
</ol>
</li>
<li>Now double click JSON Source to configure</li>
<li>In the Path / Web URL, enter API Report URL to call desired Report Start / End Date or any other expected Parameter by report (<strong>Refer to API Documentation</strong>). For our example we will enter below URL<br />
<pre class="crayon-plain-tag">https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss?fromDate=2017-02-01&amp;toDate=2017-02-28</pre>
</li>
<li>Check <strong>Use Credentials</strong> and Select Connection we created in the Previous Section</li>
<li>In the Filter enter <pre class="crayon-plain-tag">$.Reports[*].Rows[*].Rows[*]</pre></li>
<li>Now click Preview.</li>
</ol>
<p><strong>For Old Version use Properties Grid</strong></p>
<div id="attachment_8040" style="width: 946px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/configure-json-source-xero-api-extract.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8040" class="size-full wp-image-8040" src="https://zappysys.com/blog/wp-content/uploads/2017/07/configure-json-source-xero-api-extract.png" alt="Configure Xero Report Data Extract using SSIS Property Grid (For Older Version)" width="936" height="321" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/configure-json-source-xero-api-extract.png 936w, https://zappysys.com/blog/wp-content/uploads/2017/07/configure-json-source-xero-api-extract-300x103.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/configure-json-source-xero-api-extract-768x263.png 768w" sizes="(max-width: 936px) 100vw, 936px" /></a><p id="caption-attachment-8040" class="wp-caption-text">Configure Xero Report Data Extract using SSIS Property Grid (For Older Version)</p></div>
<p><strong>For New Version Use UI (It has Specify Columns Manually Option)</strong></p>
<div id="attachment_8038" style="width: 915px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-static-columns.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8038" class="size-full wp-image-8038" src="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-static-columns.png" alt="Read from Xero Report API using parameters in JSON Source in SSIS (Static Columns Example)" width="905" height="532" srcset="https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-static-columns.png 905w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-static-columns-300x176.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/07/ssis-xero-read-report-api-static-columns-768x451.png 768w" sizes="(max-width: 905px) 100vw, 905px" /></a><p id="caption-attachment-8038" class="wp-caption-text">Read from Xero Report API using parameters in JSON Source in SSIS (Static Columns Example)</p></div>
<p>&nbsp;</p>
<h2>Common Errors</h2>
<div class="content_block" id="custom_post_widget-1887"><h3>Truncation related error</h3>
<p style="text-align: justify;">The most common error you may face when you run an SSIS package is truncation error. During the design time only 300 rows are scanned from a source (a file or a REST API call response) to detect datatypes but at runtime, it is likely you will retrieve far more records. So it is possible that you will get longer strings than initially expected. For detailed instructions on how to fix common metadata related errors read an article "<a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">How to handle SSIS errors (truncation, metadata issues)</a>".</p>

<h3>Authentication related error</h3>
Another frequent error you may get is an authentication error, which happens when you deploy/copy a package to another machine and run it there. Check <a href="#Deployment_to_Production">the paragraph below</a> to see why it happens and how to solve this problem.</div>
<h2>Deployment to Production</h2>
<div class="content_block" id="custom_post_widget-1932"><p style="text-align: justify;">In SSIS package <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">sensitive data such as tokens and passwords are by default encrypted by SSIS</a> with your Windows account which you use to create a package. So SSIS will fail to decrypt tokens/passwords when you run it from another machine using another Windows account. To circumvent this when you are creating an SSIS package which uses authentication components (e.g. an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a> or an <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-http-connection-manager.htm" target="_blank" rel="noopener">HTTP Connection Manager</a> with credentials, etc.), consider using parameters/variables to pass tokens/passwords. In this way, you won’t face authentication related errors when a package is deployed to a production server.</p>
<p style="text-align: justify;">Check our article on <a href="https://zappysys.com/blog/how-to-run-an-ssis-package-with-sensitive-data-on-sql-server/" target="_blank" rel="noopener">how to configure packages with sensitive data on your production or development server</a>.</p></div>
<h2><span id="ConclusionWhat8217s_next">Conclusion. What’s next?</span></h2>
<p>In this article we have learned how to load data from Xero to SQL Server using SSIS ( drag and drop approach without coding). We used <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS JSON / REST API Connector</a> to extract data from Xero REST API using OAuth. JSON Source makes it super simple to parsing complex / large JSON Files or any Web API Response into rows and column so you can load into database like SQL Server. <a href="//zappysys.com/products/ssis-powerpack/">Download SSIS PowerPack</a> to try many other automation scenarios not discussed in this article.</p>
<p><strong>Keywords:</strong></p>
<p>Xero Integration with SQL Server | How to extract data from Xero in SSIS? | How to read data from Xero API? | Loading Xero Data into SQL Server. | Xero to SQL Server | SQL Server to Xero | SSIS Xero Integration</p>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/">How to read/load data in Xero using SSIS</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>Loading data from SQL Server to Elasticsearch with SSIS</title>
		<link>https://zappysys.com/blog/load-data-from-sql-server-to-elasticsearch-using-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Fri, 16 Jun 2017 17:08:12 +0000</pubDate>
				<category><![CDATA[HTTP Connection]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS Components]]></category>
		<category><![CDATA[SSIS Connection Manager]]></category>
		<category><![CDATA[SSIS JSON Generator Transform]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[SSIS WEB API Destination]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[elasticsearch]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis web api destination]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1365</guid>

					<description><![CDATA[<p>Introduction Elasticsearch is a powerful engine that allows you to store, aggregate, and, most importantly, search data in a very analytical way. In this tutorial, you will learn how to bulk load data from SQL Server to Elasticsearch with SSIS (part of SQL Server) and ZappySys PowerPack. The scope of this article will be to show how to import [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/load-data-from-sql-server-to-elasticsearch-using-ssis/">Loading data from SQL Server to Elasticsearch with 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/elasticsearch-connector/">API Connector for ElasticSearch</a> which makes it much simpler to <strong>Read/Write ElasticSearch 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 a learning curve with API then use a newer approach.</p>
<p>Please visit <a href="https://zappysys.com/api/integration-hub/">this page to see all</a> preconfigured ready-to-use API connectors that 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, and Informatica).</p>
</div></div>
<img loading="lazy" decoding="async" class="alignleft wp-image-1406 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180.png" alt="" width="180" height="180" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180.png 180w, https://zappysys.com/blog/wp-content/uploads/2017/06/elasticsearch-logo-180x180-150x150.png 150w" sizes="(max-width: 180px) 100vw, 180px" /></p>
<p><a href="https://www.elastic.co/" target="_blank" rel="noopener">Elasticsearch</a> is a powerful engine that allows you to store, aggregate, and, most importantly, search data in a very analytical way. In this tutorial, you will learn how to bulk load data from <em>SQL Server to Elasticsearch </em>with <a href="https://docs.microsoft.com/en-us/sql/integration-services/sql-server-integration-services" target="_blank" rel="noopener"><acronym title="SQL Server Integration Services">SSIS</acronym></a> (part of SQL Server) and <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys PowerPack</a>.</p>
<p>The scope of this article will be to show how to import records from SQL Server into Elasticsearch index as JSON documents using <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html" target="_blank" rel="noopener">Elasticsearch Bulk API</a>. In a nutshell, we will retrieve IDs and names of the products from a SQL table, transform each row into a JSON and lastly, index each JSON in Elasticsearch under record&#8217;s corresponding ID. This tutorial is going to be your stepping stone to use any Elasticsearch API as a destination.</p>
<p>We will be using these SSIS components of PowerPack to make things work:</p>
<div class="su-table su-table-alternate">
<table width="276">
<tbody>
<tr style="line-height: 0px">
<td width="50px"><a href="//zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-1382" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-generator-transform.png" alt="" width="50" height="50" /></a></td>
<td style="vertical-align: middle"><a href="//zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">JSON Generator Transform</a></td>
</tr>
<tr style="line-height: 0px">
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="alignnone wp-image-1383" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-web-api-destination.png" alt="" width="50" height="50" /></a></td>
<td style="vertical-align: middle"><a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a></td>
</tr>
</tbody>
</table>
</div>
<p>Let&#8217;s begin?</p>
<h2>Prerequisites</h2>
<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><em>Northwind</em> database deployed on your machine (we will use it to load data from; <a href="//zappysys.com/blog/wp-content/uploads/2017/06/Northwind.zip" target="_blank" rel="noopener">download it</a>).</li>
<li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html" target="_blank" rel="noopener"><i>Elasticsearch </i>instance up and running</a>.</li>
<li><a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener"><em>ZappySys SSIS PowerPack</em> installed</a>.</li>
</ol>
<p>&nbsp;</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> If your ElasticSearch instance is hosted as <a href="https://aws.amazon.com/elasticsearch-service/" target="_blank" rel="noopener">AWS Managed ElasticSearch Instance</a> then select  <pre class="crayon-plain-tag">&lt;New ZS-OAUTH Connection&gt;</pre>. rather than ZS-HTTP (Explained later in this article). When OAuth UI launches select AWS v4 Provider. For more information on <a href="https://zappysys.com/blog/how-to-call-amazon-aws-api-using-ssis-ec2-lambda-api-gateway-sqs/" target="_blank" rel="noopener">calling REST API on AWS check this article</a>. </div></div>
<h2>Step-by-Step – Bulk loading data from SQL Server to Elasticsearch with SSIS</h2>
<h3>Load data from SQL Server database first</h3>
<p>In this section, you will perform several basic steps to start the package: load data from SQL Server and prepare it for further steps.</p>
<ol>
<li>Create a new SSIS package and drag a <em>Data Flow Task</em> into the <em>Control Flow</em> from the SSIS Toolbox.
<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>Open <em>Data Flow Task</em> and then add <em>OLE DB Source.</em></li>
<li>Configure OLE DB Source to take data from <em>Products </em>table<em>, Northwind</em> database.</li>
<li>Choose <em>ProductID</em> and <em>ProductName</em> as columns you will use.
<div id="attachment_2394" style="width: 251px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-control-flow-3.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2394" class="wp-image-2394 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-control-flow-3.png" alt="Load data to Elasticsearch using SSIS and ZappySys Web API Destination component." width="241" height="306" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-control-flow-3.png 241w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-control-flow-3-236x300.png 236w" sizes="(max-width: 241px) 100vw, 241px" /></a><p id="caption-attachment-2394" class="wp-caption-text">Load data to Elasticsearch using SSIS and ZappySys Web API Destination component.</p></div></li>
</ol>
<h3>Transform data into JSON documents</h3>
<p>To add data into Elasticsearch firstly we need to prepare it with <em>JSON Generator Transform. </em>It will help us convert table rows into JSON documents.</p>
<h4>JSON String to Create Index data for the Bulk API call</h4>
<ol>
<li>Close the window and then drag <em>Derived Column </em>component from the SSIS Toolbox.</li>
<li>Furthermore, Add two new columns and name them <pre class="crayon-plain-tag">RowHeader</pre> and <pre class="crayon-plain-tag">RowFooter</pre>:
<div id="attachment_2406" style="width: 691px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2406" class="wp-image-2406 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png" alt="Derived Column configuration to add prefix and header and footer to a JSON" width="681" height="443" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png 681w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2-300x195.png 300w" sizes="(max-width: 681px) 100vw, 681px" /></a><p id="caption-attachment-2406" class="wp-caption-text">Derived Column configuration to add prefix and header and footer to a JSON</p></div>
<p>In the <em>Expression</em> column give them values:</p>
<ul>
<li><strong>RowHeader</strong>:<br />
<pre class="crayon-plain-tag">"{ \"index\": { \"_index\": \"shop\", \"_type\": \"products\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n"</pre>
</li>
<li><strong>RowFooter</strong>:  <pre class="crayon-plain-tag">"\n"</pre></li>
</ul>
</li>
<li>Now drag <em>JSON Generator Transform</em> from the SSIS Toolbox and open it.</li>
<li>Right mouse click on item <em>Mappings </em>and select <pre class="crayon-plain-tag">Add Element(s) (Below this node)</pre>:
<div id="attachment_1415" style="width: 330px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1415" class="wp-image-1415 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping.png" alt="Convert SQL table rows into JSON using JSON Generator Transform" width="320" height="116" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping.png 320w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping-300x109.png 300w" sizes="(max-width: 320px) 100vw, 320px" /></a><p id="caption-attachment-1415" class="wp-caption-text">Convert SQL table rows into JSON using <em>JSON Generator Transform</em></p></div></li>
<li>Once a dialog appears, select <pre class="crayon-plain-tag">ProductName</pre> as <em>Source Column</em> and <pre class="crayon-plain-tag">name</pre> as <em>Output Alias:<br />
</em></p>
<div id="attachment_1526" style="width: 386px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping-3.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1526" class="size-full wp-image-1526" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping-3.jpg" alt="Map table column to JSON property using JSON Generator Transform" width="376" height="438" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping-3.jpg 376w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-json-generator-transform-add-mapping-3-258x300.jpg 258w" sizes="(max-width: 376px) 100vw, 376px" /></a><p id="caption-attachment-1526" class="wp-caption-text">Map table column to JSON property using <em>JSON Generator Transform</em></p></div></li>
<li>You should get a similar view:
<div id="attachment_2396" style="width: 728px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2396" class="wp-image-2396 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-2.png" alt="JSON Generator Transform configuration to create JSON from a SQL table" width="718" height="320" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-2.png 718w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-2-300x134.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></a><p id="caption-attachment-2396" class="wp-caption-text"><em>JSON Generator Transform</em> configuration to create JSON from a SQL table</p></div></li>
<li>Then go to <em>Header / Footer</em> tab and:
<ul>
<li>Select <pre class="crayon-plain-tag">Direct String</pre> option.</li>
<li>Input <pre class="crayon-plain-tag">&lt;%RowHeader%&gt;</pre> in <em>Header String</em> option.</li>
<li>Input <pre class="crayon-plain-tag">&lt;%RowFooter%&gt;</pre> in <em>Footer String</em> option.</li>
</ul>
<div id="attachment_2403" style="width: 728px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-3-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2403" class="wp-image-2403 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-3-1-e1513951668585.png" alt="JSON Generator Transform configuration to convert rows into JSON suitable for Elasticsearch Bulk operation" width="718" height="400" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-3-1-e1513951668585.png 718w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-convert-rows-into-json-using-json-generator-transform-3-1-e1513951668585-300x167.png 300w" sizes="(max-width: 718px) 100vw, 718px" /></a><p id="caption-attachment-2403" class="wp-caption-text"><em>JSON Generator Transform</em> configuration to convert rows into JSON suitable for Elasticsearch Bulk operation</p></div></li>
<li>Close the window.</li>
</ol>
<h4>JSON String to Update Index data for the Bulk API call</h4>
<p>From the above section &#8220;<strong>JSON String to Create Index data for the Bulk API call&#8221; </strong>follows all the steps From <strong>Step-1 to Step-8.</strong></p>
<p>Just for (2nd step) <strong>Step-2</strong> use below expression for  <pre class="crayon-plain-tag">RowHeader</pre> and <pre class="crayon-plain-tag">RowFooter</pre>
<a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png"><img loading="lazy" decoding="async" class="wp-image-2406 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png" alt="Derived Column configuration to add prefix and header and footer to a JSON" width="681" height="443" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png 681w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2-300x195.png 300w" sizes="(max-width: 681px) 100vw, 681px" /></a></p>
<p>Derived Column configuration to add prefix and header and footer to a JSONIn the <em>Expression</em> column give them values:</p>
<ul>
<li><strong>RowHeader</strong>:<br />
<pre class="crayon-plain-tag">"{ \"update\": { \"_index\": \"shop\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n{ \"doc\" : "</pre>
</li>
<li><strong>RowFooter</strong>:  <pre class="crayon-plain-tag">"}\n"</pre></li>
</ul>
<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>: To learn how to make more complicated transforms visit these links:</p>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">https://zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/</a> (check the video)</li>
<li><a href="https://zappysys.com/blog/tag/ssis-json-generator-transform/" target="_blank" rel="noopener">https://zappysys.com/blog/tag/ssis-json-generator-transform/</a></li>
</ul>
</div></div>
<h4>JSON String to Delete Index data for the Bulk API call</h4>
<p>From the above section &#8220;<strong>JSON String to Create Index data for the Bulk API call&#8221; </strong>follows steps <strong>Step-1 and Step-2.</strong></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>: No need to use JSON Generator Transform (From Step-3). </div></div>
<p>Just for (2nd step) <strong>Step-2</strong> use below expression for  <pre class="crayon-plain-tag">RowHeader</pre>
<a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png"><img loading="lazy" decoding="async" class="wp-image-2406 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png" alt="Derived Column configuration to add prefix and header and footer to a JSON" width="681" height="443" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2.png 681w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-derived-columns-2-300x195.png 300w" sizes="(max-width: 681px) 100vw, 681px" /></a></p>
<p>Derived Column configuration to add prefix and header and footer to a JSON</p>
<p>In the <em>Expression</em> column give them values:</p>
<ul>
<li><strong>RowHeader</strong>:<br />
<pre class="crayon-plain-tag">"{ \"delete\": { \"_index\": \"shop\", \"_id\" : \"" + (DT_WSTR,100)ProductID + "\" } }\n"</pre>
</li>
</ul>
<h3>Finally, Elasticsearch &amp; SQL Server integration</h3>
<ol>
<li>Now drag <em>Web API Destination</em> SSIS component into the Data Flow and open it for editing.</li>
<li>In <em>Select Connection</em> section press <pre class="crayon-plain-tag">&lt;New ZS-HTTP Connection&gt;</pre>.<br />
<strong>NOTE:</strong> If your ElasticSearch instance is hosted as AWS Managed Service then select  <pre class="crayon-plain-tag">&lt;New ZS-OAUTH Connection&gt;</pre>. rather than ZS-HTTP. When OAuth UI launches select AWS v4 Provider. For more information on <a href="https://zappysys.com/blog/how-to-call-amazon-aws-api-using-ssis-ec2-lambda-api-gateway-sqs/" target="_blank" rel="noopener">calling REST API on AWS check this article</a>.</li>
<li>Once <em>HTTP Connection Manager</em> window opens configure connection to your Elasticsearch instance:
<ul>
<li>Set <em>Web Url</em>, which points to your Elasticsearch instance.</li>
<li>Set <em>Credentials Type</em> to <pre class="crayon-plain-tag">Basic - UserID/Password</pre> (or other appropriate authentication method).</li>
<li>Finally, set <em>User Name</em> and <em>Password:<br />
</em></p>
<div id="attachment_1419" style="width: 330px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1419" class="wp-image-1419 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png" alt="Configure SSIS HTTP Connection to connect to Elasticsearch" width="320" height="207" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection.png 320w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-post-data-to-elasticsearch-configure-http-connection-300x194.png 300w" sizes="(max-width: 320px) 100vw, 320px" /></a><p id="caption-attachment-1419" class="wp-caption-text">Configure SSIS <em>HTTP Connection</em> to connect to Elasticsearch</p></div></li>
</ul>
</li>
<li>Close configuration window. Now it&#8217;s time to configure <em>Web API Destination</em>.</li>
<li>All that is separating you from getting those rows into Elasticsearch is:
<ul>
<li>Setting <em>Input Column</em> <em>for Body</em> to <pre class="crayon-plain-tag">ZS_JSON_OUT</pre> for <strong>Create and Update</strong> Index Data and for <strong>Delete</strong> Index Data <em>Input Column for Body</em> to <pre class="crayon-plain-tag">RowHeader [Derived Column]</pre>.</li>
<li>Setting <em>URL</em> to <pre class="crayon-plain-tag">http://localhost:9200/_bulk</pre>.</li>
<li>Setting <em>HTTP Request</em> Method to <pre class="crayon-plain-tag">POST</pre>.</li>
</ul>
<div id="attachment_2397" style="width: 711px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2397" class="wp-image-2397 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-2.png" alt="Index SQL Server Database data in Elasticsearch using SSIS component &quot;Web API Destination&quot;" width="701" height="623" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-2.png 701w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-2-300x267.png 300w" sizes="(max-width: 701px) 100vw, 701px" /></a><p id="caption-attachment-2397" class="wp-caption-text">Index SQL Server Database data in Elasticsearch using SSIS component <em>Web API Destination</em></p></div></li>
<li>Then open <em>Batch Settings (For Body)</em> tab:
<ul>
<li>Enable batch submission.</li>
<li>Set <em>Body Batch Size, </em>e.g. 1000<em>. </em>Make sure this number is even, otherwise you may get into problems (Elasticsearch Bulk request has special JSON request body format, as you perhaps noticed).</li>
</ul>
<div id="attachment_2415" style="width: 711px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-3.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2415" class="wp-image-2415 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-3.png" alt="Web API Destination batch settings configuration" width="701" height="623" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-3.png 701w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-post-data-to-elasticsearch-web-api-destination-3-300x267.png 300w" sizes="(max-width: 701px) 100vw, 701px" /></a><p id="caption-attachment-2415" class="wp-caption-text"><em>Web API Destination</em> batch settings configuration</p></div></li>
<li>Close the window and run the package! You should see green lights, telling you everything is OK:
<div id="attachment_2398" style="width: 302px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-load-success-2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2398" class="wp-image-2398 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-load-success-2.png" alt="Successful data load from SQL Server to Elasticsearch" width="292" height="391" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-load-success-2.png 292w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-load-success-2-224x300.png 224w" sizes="(max-width: 292px) 100vw, 292px" /></a><p id="caption-attachment-2398" class="wp-caption-text">Successful data load from SQL Server to Elasticsearch</p></div></li>
<li>We can also query Elasticsearch by using one of its <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search.html" target="_blank" rel="noopener">Search APIs</a> &#8211; <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html" target="_blank" rel="noopener">URI Search</a> to see if we successfully indexed data:
<div id="attachment_1470" style="width: 363px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-load-results.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1470" class="wp-image-1470" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-load-results.png" alt="SQL Server data index in Elasticsearch" width="353" height="450" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-load-results.png 429w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-load-results-235x300.png 235w" sizes="(max-width: 353px) 100vw, 353px" /></a><p id="caption-attachment-1470" class="wp-caption-text">SQL Server data index in Elasticsearch</p></div></li>
<li>Rows number match in SSIS and in search results, thus everything is good. You are done.</li>
</ol>
<h3>What if I want more? After upserting data use <em>Web API Destination</em> further</h3>
<p>Let&#8217;s say you have a requirement to do something with rows that were freshly indexed in Elasticsearch. Then you will need somehow to distinguish between created and updated records in Elasticsearch. And that won&#8217;t be difficult because <em>Web API Destination</em> acts not only as <span style="text-decoration: underline;">Destination</span> but as <span style="text-decoration: underline;">Transformation</span> as well. So one thing you have to do is connect <em><a href="//zappysys.com/products/ssis-powerpack/ssis-json-parser-transform/" target="_blank" rel="noopener">JSON Parser Transform</a></em> downstream to <em>Web API Destination</em>. It will parse Elasticsearch HTTP JSON response – which is returned by <em>Web API Destination –</em> into columns, which you can later easily redirect using <em>Conditional Split:</em></p>
<ol>
<li>Add <em>JSON Parser Transform</em> and connect it to <em>Web API Destination</em>:
<div id="attachment_1476" style="width: 415px" class="wp-caption alignnone"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1476" class="size-full wp-image-1476" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-http-response-parsing.png" alt="Add JSON Parser Transform to get Elasticsearch HTTP JSON response when integrating SQL Server &amp; Elasticsearch" width="405" height="394" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-http-response-parsing.png 405w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-http-response-parsing-300x292.png 300w" sizes="(max-width: 405px) 100vw, 405px" /><p id="caption-attachment-1476" class="wp-caption-text">Use <em>JSON Parser Transform</em> to get Elasticsearch HTTP JSON response when integrating SQL Server &amp; Elasticsearch</p></div></li>
<li>Make sure you have selected <pre class="crayon-plain-tag">ResponseText</pre> as <em>Select Input JSON Column.</em></li>
<li>Then go to <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html" target="_blank" rel="noopener">Bulk API</a> and copy/paste &#8220;the result of this bulk operation&#8221; JSON response:
<div id="attachment_2399" style="width: 714px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2399" class="wp-image-2399 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png" alt="Using JSON Parser Transform to parse JSON response from REST HTTP request" width="704" height="622" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration.png 704w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-json-parser-transform-configuration-300x265.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></a><p id="caption-attachment-2399" class="wp-caption-text">Using <em>JSON Parser Transform</em> to parse JSON response from REST HTTP request</p></div></li>
<li>Set <pre class="crayon-plain-tag">$.items[*]</pre> as the filter.</li>
<li><strong>Optional step</strong>. You won&#8217;t find a response sample for every Elasticsearch API call. In that case, you may want to use <a href="http://www.getpostman.com" target="_blank" rel="noopener">Postman</a> to make an HTTP request to Elasticsearch and get a sample response:
<div id="attachment_1513" style="width: 589px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-using-postman-to-troubleshoot.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1513" class="wp-image-1513 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-using-postman-to-troubleshoot.png" alt="Use Postman to make a request to Elasticsearch and get a sample response to be used in JSON Parser Transform" width="579" height="587" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-using-postman-to-troubleshoot.png 579w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-using-postman-to-troubleshoot-296x300.png 296w" sizes="(max-width: 579px) 100vw, 579px" /></a><p id="caption-attachment-1513" class="wp-caption-text">Use <em>Postman</em> to make a request to Elasticsearch and get a sample response to be used in <em>JSON Parser Transform</em></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>: Don&#8217;t forget to set the username and password in <em>Authorization</em> section!</div></div></li>
<li>Then use a <em>Conditional Split </em>and <a href="//zappysys.com/onlinehelp/ssis-powerpack/index.htm#page=trash-destination.htm" target="_blank" rel="noopener">Trash Destination</a> to redirect the rows:<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-conditional-split.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2410" src="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-conditional-split.png" alt="" width="893" height="394" srcset="https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-conditional-split.png 893w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-conditional-split-300x132.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/12/ssis-sql-server-to-elasticsearch-conditional-split-768x339.png 768w" sizes="(max-width: 893px) 100vw, 893px" /></a><br />
Input these clauses:</p>
<ul>
<li><strong>Inserted</strong>:<br />
<pre class="crayon-plain-tag">REPLACENULL([index.result],"") == "created" || REPLACENULL([create.result],"") == "created"</pre>
</li>
<li><strong>Updated</strong>:<br />
<pre class="crayon-plain-tag">REPLACENULL([index.result],"") == "updated" || REPLACENULL([create.result],"") == "updated"</pre>
</li>
</ul>
</li>
<li>As a result, new index records will be redirected to one destination, while updated records &#8211; to the other:<br />
<a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-integration-results.png"><img loading="lazy" decoding="async" width="423" height="388" class="wp-image-1478 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-integration-results.png" alt="&quot;Result" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-integration-results.png 423w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-integration-results-300x275.png 300w" sizes="(max-width: 423px) 100vw, 423px" /></a></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>: <em>Trash Destination</em> is a handy component of <em>ZappySys PowerPack</em> which can be used as dummy destination when we don&#8217;t care about the destination (and we don&#8217;t care in this tutorial) 🙂</div></div>
<p>Overall you can use <em>Web API Destination</em> HTTP JSON response for other useful things as well, e.g. determine on how many <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/_basic_concepts.html#getting-started-shards-and-replicas" target="_blank" rel="noopener">replica shards</a> record was indexed. JSON response will depend on which Elasticsearch API and which method you use.</p>
<h3>Delete Index by making an API call.</h3>
<p>If you want to delete the index by making <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html" target="_blank" rel="noopener">Delete API</a> call you can. Let&#8217;s make that call using the Rest API Task. Configure it like below screen and click on the Test Request button.</p>
<div id="attachment_8605" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-rest-api-task-delete-method.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-8605" class="wp-image-8605 size-medium_large" src="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-rest-api-task-delete-method-768x523.png" alt="Rest API Delete Method" width="720" height="490" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-rest-api-task-delete-method-768x523.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-rest-api-task-delete-method-300x204.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-rest-api-task-delete-method.png 901w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-8605" class="wp-caption-text">Rest API Delete Method</p></div>
<h3>Things went bad: Error handling &amp; debugging</h3>
<p>Incidentally, you may incorrectly construct JSON for <em>Web API Destination</em> body<i>. </i>Elasticsearch nodes may go offline or 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 failed requests from <em>Web API Destination</em> to some other destination:</p>
<ol>
<li>Add a <em>Derived Column</em> above <em>Web API Destination</em> with expression <pre class="crayon-plain-tag">(DT_WSTR,4000)ZS_JSON_OUT</pre> and name it <pre class="crayon-plain-tag">JsonAsString</pre>. This will let you see what JSON you are actually passing.</li>
<li>After that, add 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>Web API Destination </em>into it<em>. </em>Don&#8217;t forget to set <pre class="crayon-plain-tag">Redirect row</pre> option for both, <em>Error</em> and <em>Truncation</em> columns:<em><br />
</em><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows.png"><img loading="lazy" decoding="async" width="739" height="267" class="wp-image-1487 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling-redirecting-bad-rows.png" alt="&quot;Redirect" 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></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 id="attachment_1494" style="width: 762px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-sql-server-to-elasticsearch-error-handling.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1494" class="wp-image-1494 size-full" src="//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 id="caption-attachment-1494" class="wp-caption-text">Use<em> Data Viewer</em> to view HTTP requests that failed to be fulfilled in Elasticsearch</p></div></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>: 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>
<h2>Call ElasticSearch API hosted on AWS</h2>
<p>If your ElasticSearch instance is hosted as <a href="https://aws.amazon.com/elasticsearch-service/" target="_blank" rel="noopener">AWS Managed ElasticSearch Instance</a> then select  <pre class="crayon-plain-tag">&lt;New ZS-OAUTH Connection&gt;</pre>. rather than ZS-HTTP (Explained later in this article). When OAuth UI launches select AWS v4 Provider. For more information on <a href="https://zappysys.com/blog/how-to-call-amazon-aws-api-using-ssis-ec2-lambda-api-gateway-sqs/" target="_blank" rel="noopener">calling REST API on AWS check this article</a>.</p>
<div id="attachment_6277" style="width: 836px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/11/ssis-call-aws-elasticsearch-rest-api-sign-v4.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6277" class="size-full wp-image-6277" src="https://zappysys.com/blog/wp-content/uploads/2017/11/ssis-call-aws-elasticsearch-rest-api-sign-v4.png" alt="Call AWS Hosted ElasticSearch REST API in SSIS (V4 Request Signing)" width="826" height="730" srcset="https://zappysys.com/blog/wp-content/uploads/2017/11/ssis-call-aws-elasticsearch-rest-api-sign-v4.png 826w, https://zappysys.com/blog/wp-content/uploads/2017/11/ssis-call-aws-elasticsearch-rest-api-sign-v4-300x265.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/11/ssis-call-aws-elasticsearch-rest-api-sign-v4-768x679.png 768w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-6277" class="wp-caption-text">Call AWS Hosted ElasticSearch REST API in SSIS (V4 Request Signing)</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 a sample package</h2>
<p>Be sure to download a <a href="https://zappysys.com/blog/wp-content/uploads/2017/06/Bulk-load-data-from-SQL-Server-to-Elasticsearch-using-SSIS.zip">sample SQL Server 2008 SSIS package</a>, in case you want to try it right away (you can upgrade it to a higher version).<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>: Once you open the package, you won’t be able to run it immediately, but don’t panic. Just configure OLE DB Source to point to your Northwind database and set URLs to point to your Elasticsearch instance.</div></div>
<h2>Conclusion. What&#8217;s next?</h2>
<p>In conclusion, in this article we have learned how to bulk load data from SQL Server and upsert it in Elasticsearch index. We used <a href="//zappysys.com/products/ssis-powerpack/ssis-json-generator-transform/" target="_blank" rel="noopener">JSON Generator Transform</a> to help us convert database table rows into JSON documents. In addition, <a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> was very helpful in automatically creating and making HTTP requests to Elasticsearch instance and indexing our data as a result. This tutorial was quite simple and straightforward, yet it is a good starter to use other Elasticsearch APIs and their features. From now on <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" target="_blank" rel="noopener">Elasticsearch reference</a> is your best friend in learning what APIs exist, what are their methods and how HTTP requests should look like.</p>
<p><strong>Keywords</strong></p>
<p>How to import data from SQL Server to Elasticsearch | How to load data into Elasticsearch | Using Elasticsearch to index SQL Server | Elasticsearch and SQL Server integration | How to use Elasticsearch together with SQL Server | Upsert SQL Server data into Elasticsearch</p>
<p>The post <a href="https://zappysys.com/blog/load-data-from-sql-server-to-elasticsearch-using-ssis/">Loading data from SQL Server to Elasticsearch with SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to get data from HubSpot API with SSIS</title>
		<link>https://zappysys.com/blog/get-data-from-hubspot-api-with-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Fri, 02 Jun 2017 15:31:16 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS Components]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[hubspot]]></category>
		<category><![CDATA[HubSpot API]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[OAuth Connection]]></category>
		<category><![CDATA[RESTful API]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[ssis json source]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=1175</guid>

					<description><![CDATA[<p>Introduction HubSpot is a popular platform where CRM, Marketing and Sales meet in one place. It&#8217;s a good piece of service, yet sometimes you need to integrate it with your other system. In this article you will learn how to pull contacts from HubSpot API and load them into a SQL Server Database using SSIS and ZappySys [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/get-data-from-hubspot-api-with-ssis/">How to get data from HubSpot API with 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/hubspot-connector/">API Connector for Hubspot Connector</a> which makes it much simpler to <strong>Read/Write Hubspot 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><a href="//zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-integration-2.png"><img loading="lazy" decoding="async" class="wp-image-1862 alignleft" src="//zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-integration-2.png" alt="" width="110" height="110" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-integration-2.png 180w, https://zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-integration-2-150x150.png 150w" sizes="(max-width: 110px) 100vw, 110px" /></a><a href="http://www.hubspot.com" target="_blank" rel="noopener">HubSp</a><a href="http://www.hubspot.com" target="_blank" rel="noopener">ot</a> is a popular platform where CRM, Marketing and Sales meet in one place. It&#8217;s a good piece of service, yet sometimes you need to integrate it with your other system. In this article you will learn how to pull contacts from <a href="https://developers.hubspot.com/docs/overview" target="_blank" rel="noopener">HubSpot API</a> and load them into a SQL Server Database using SSIS and <a href="//zappysys.com/products/ssis-powerpack/">ZappySys SSIS PowerPack</a>.</p>
<p>&nbsp;</p>
<h2>Prerequisites</h2>
<ol>
<li>HubSpot Account registered (an account you will want to get data from).</li>
<li>SSIS designer installed. Sometimes it is referred as BIDS or SSDT (<a href="https://msdn.microsoft.com/en-us/mt186501" 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>An existing SQL Server Database and table created (we will use it to load data into).</li>
<li><em>ZappySys SSIS PowerPack</em> installed.</li>
</ol>
<h2>Various methods to call HubSpot API</h2>
<p>HubSpot API supports two kinds of authentication:</p>
<ol>
<li>OAuth 2.0.</li>
<li>API Key in URL.</li>
</ol>
<p><em>API Key in URL</em> is simple, with minimal configuration, but it ought to be used only for development and testing purposes.</p>
<p>In this tutorial we will show how to authenticate using <em>OAuth 2.0</em>, which you should use in your production environment.</p>
<h2>Step-by-Step <span id="Step-By-StepGet_data_from_HubSpot_REST_API"><span id="Step-By-Step_8211_Call_Amazon_MWS_API_using_SSIS">– </span></span>Get data from HubSpot API into SQL Server database</h2>
<ol>
<li>Create HubSpot Developer Account (<a href="https://app.hubspot.com/signup/developers" target="_blank" rel="noopener">https://app.hubspot.com/signup/developers</a>). It&#8217;s an account you will need to use to create HubSpot Apps.</li>
<li>Login with your HubSpot Developer Account (<a href="https://app.hubspot.com/login" target="_blank" rel="noopener">https://app.hubspot.com/login</a>).</li>
<li>Select your newly created HubSpot Developer Account:
<div id="attachment_1205" style="width: 460px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-developer-account1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1205" class="wp-image-1205 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-developer-account1.png" alt="Logging into HubSpot - select HubSpot developer account" width="450" height="149" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-developer-account1.png 450w, https://zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-developer-account1-300x99.png 300w" sizes="(max-width: 450px) 100vw, 450px" /></a><p id="caption-attachment-1205" class="wp-caption-text">Logging into HubSpot &#8211; Select HubSpot developer account</p></div>
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Account name should contain &#8220;hubspot-developers&#8221; text.</div></div></li>
<li>Register HubSpot OAuth App for REST API Call for use with OAuth 2.0 by simply pressing &#8220;Create application&#8221; button:
<div id="attachment_1200" style="width: 398px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/create-hubspot-application.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1200" class="wp-image-1200" src="//zappysys.com/blog/wp-content/uploads/2017/06/create-hubspot-application.png" alt="Register HubSpot OAuth App for REST API Call for use with OAuth 2.0 " width="388" height="339" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/create-hubspot-application.png 511w, https://zappysys.com/blog/wp-content/uploads/2017/06/create-hubspot-application-300x262.png 300w" sizes="(max-width: 388px) 100vw, 388px" /></a><p id="caption-attachment-1200" class="wp-caption-text">Register HubSpot OAuth App for REST API Call for use with OAuth 2.0</p></div></li>
<li>Name the application (e.g. &#8220;ContactsApp&#8221;) and choose &#8220;Private&#8221; to make the application hidden from the outer and dangerous world 🙂
<div id="attachment_1201" style="width: 395px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/name-hubspot-application.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1201" class="wp-image-1201" src="//zappysys.com/blog/wp-content/uploads/2017/06/name-hubspot-application.png" alt="Name HubSpot REST API App which will be used from within SSIS" width="385" height="333" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/name-hubspot-application.png 448w, https://zappysys.com/blog/wp-content/uploads/2017/06/name-hubspot-application-300x259.png 300w" sizes="(max-width: 385px) 100vw, 385px" /></a><p id="caption-attachment-1201" class="wp-caption-text">Name HubSpot REST API App which will be used from within SSIS</p></div></li>
<li>Press &#8220;Edit&#8221; button on the app you just created.</li>
<li>Write down <em>Client ID</em> and <em>Client secret</em>. We will need them later for authentication:
<div id="attachment_1203" style="width: 867px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/note-hubspot-client-id-and-client-secret.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1203" class="wp-image-1203" src="//zappysys.com/blog/wp-content/uploads/2017/06/note-hubspot-client-id-and-client-secret-1024x458.png" alt="Write down Client ID and Client Secret which will be used in OAuth Connection SSIS component" width="857" height="383" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/note-hubspot-client-id-and-client-secret-1024x458.png 1024w, https://zappysys.com/blog/wp-content/uploads/2017/06/note-hubspot-client-id-and-client-secret-300x134.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/06/note-hubspot-client-id-and-client-secret.png 1090w" sizes="(max-width: 857px) 100vw, 857px" /></a><p id="caption-attachment-1203" class="wp-caption-text">Write down Client ID and Client Secret which will be used in OAuth Connection SSIS component</p></div></li>
<li>Open <em>SSIS Designer</em> and create a new package.</li>
<li>Drag a new <em>Data Flow </em>task from <em>SSIS Toolbox</em> into the <em><em>Control Flow:<br />
</em></em></p>
<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>Edit<em> Data Flow </em>task by double clicking<em>. </em>Then drag <em>ZS JSON Source</em> and <em>OLE DB Destination</em> components from <em>SSIS Toolbox </em>into the<em> Data Flow, </em>but don&#8217;t connect them yet:<em><em><br />
</em></em></p>
<div id="attachment_1207" style="width: 598px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/drag-json-source-into-data-flow.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1207" class="wp-image-1207 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/drag-json-source-into-data-flow.png" alt="Drag ZappySys JSON Source SSIS component into the Data Flow" width="588" height="200" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/drag-json-source-into-data-flow.png 588w, https://zappysys.com/blog/wp-content/uploads/2017/06/drag-json-source-into-data-flow-300x102.png 300w" sizes="(max-width: 588px) 100vw, 588px" /></a><p id="caption-attachment-1207" class="wp-caption-text">Drag ZappySys JSON Source SSIS component into the Data Flow</p></div></li>
<li>Start editing <em>JSON Source</em> component:
<ol>
<li>Set <em>Access Mode</em> to <em>File path or web URL</em>.</li>
<li>Set <em>Web URL</em> to <pre class="crayon-plain-tag">https://api.hubapi.com/contacts/v1/lists/all/contacts/all?count=100</pre><em><em>.<br />
</em></em><div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: We are adding URL parameter with value <pre class="crayon-plain-tag">?count=100</pre>, because by default HubSpot API returns 20 contacts and we want to maximize result set and minimize the number of web requests.</div></div></li>
<li>Press <em>Select Filter </em>and select contacts node or simply enter <pre class="crayon-plain-tag">$.contacts[*]</pre>  into the text box<em>.</em></li>
<li>Check <em>Use Credentials</em> checkbox.</li>
<li>Select <em>&lt;New ZS-OAUTH Connection&gt;</em> menu item to create a new connection:
<div id="attachment_1209" style="width: 836px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/edit-json-source-for-getting-data-from-hubspot.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1209" class="wp-image-1209 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/edit-json-source-for-getting-data-from-hubspot.png" alt="JSON Source SSIS component configuration – Get data from HubSpot REST API using OAuth authentication" width="826" height="733" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/edit-json-source-for-getting-data-from-hubspot.png 826w, https://zappysys.com/blog/wp-content/uploads/2017/06/edit-json-source-for-getting-data-from-hubspot-300x266.png 300w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-1209" class="wp-caption-text">JSON Source SSIS component configuration – Get data from HubSpot API using OAuth authentication</p></div></li>
</ol>
</li>
<li>Configure OAuth 2.0 connection for HubSpot API:
<ol>
<li>Select <em>HubSpot</em> as <em>OAuth Provider</em>.</li>
<li>Select &#8220;Use Custom OAuth (App created by you)&#8221; option.<br />
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: You can also use Default OAuth App option for a quick test. Select it and press &#8220;<em>Generate Token</em>&#8221; button after you enter the scope.</div></div></li>
<li>Paste <em>Client Id</em> and <em>Client Secret</em> you also saved in Step #7.</li>
<li>Input <pre class="crayon-plain-tag">contacts</pre> as our scope.</li>
<li>Finally, press &#8220;<em>Generate Token&#8221;</em> button:
<div id="attachment_1308" style="width: 781px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/configure-ssis-oauth-connection-for-hubspot-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1308" class="wp-image-1308 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/configure-ssis-oauth-connection-for-hubspot-api.png" alt="OAuth Connection SSIS component configuration - Connect to HubSpot API using OAuth 2.0" width="771" height="697" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/configure-ssis-oauth-connection-for-hubspot-api.png 771w, https://zappysys.com/blog/wp-content/uploads/2017/06/configure-ssis-oauth-connection-for-hubspot-api-300x271.png 300w" sizes="(max-width: 771px) 100vw, 771px" /></a><p id="caption-attachment-1308" class="wp-caption-text">OAuth Connection SSIS component configuration &#8211; Connect to HubSpot API using OAuth 2.0</p></div></li>
</ol>
</li>
<li>Select your <span style="text-decoration: underline;">ordinary</span> HubSpot account you want to get contacts from:
<div id="attachment_1212" style="width: 638px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-ordinary-account.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1212" class="wp-image-1212 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-ordinary-account.png" alt="OAuth Connection SSIS component configuration - Select a HubSpot account to get data from" width="628" height="385" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-ordinary-account.png 628w, https://zappysys.com/blog/wp-content/uploads/2017/06/select-hubspot-ordinary-account-300x184.png 300w" sizes="(max-width: 628px) 100vw, 628px" /></a><p id="caption-attachment-1212" class="wp-caption-text">OAuth Connection SSIS component configuration &#8211; Select a HubSpot account to get data from</p></div>
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Account name should NOT contain &#8220;hubspot-developers&#8221; text.</div></div></li>
<li>Grant access to your HubSpot App:
<div id="attachment_1214" style="width: 818px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/grant-access-to-hubspot-app.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1214" class="wp-image-1214 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/grant-access-to-hubspot-app-e1496844506831.png" alt="OAuth Connection SSIS component configuration - Grant access to HubSpot REST API App" width="808" height="364" /></a><p id="caption-attachment-1214" class="wp-caption-text">OAuth Connection SSIS component configuration &#8211; Grant access to HubSpot API App</p></div></li>
<li>You will get a prompt to save <em>Access</em> and <em>Refresh</em> tokens to a backup file. Press &#8220;Yes&#8221; to save them.<br />
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: You will need to pass <pre class="crayon-plain-tag">Refresh Token</pre> as the parameter, when you run the package in another machine. Check <em>Deployment to Production</em> section for more info.</div></div></li>
<li>Configure HubSpot API pagination
<div>
<ol>
<li>Set <em>Next Link/Cursor Expression</em> to <pre class="crayon-plain-tag">$.vid-offset</pre>  by pressing &#8220;&#8230;&#8221; button or simply pasting the value into the text box.</li>
<li>In the same way set <em>Stop Indicator/Attribute</em> to <pre class="crayon-plain-tag">$.has-more</pre>.</li>
<li>Input <pre class="crayon-plain-tag">false</pre> as <em>Stop indicator value/Regular expression</em>.</li>
<li>Set <em>Suffix for Next Url</em> to <pre class="crayon-plain-tag">&amp;vidOffset=&lt;%nextlink%&gt;</pre>.
<div id="attachment_1236" style="width: 836px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-pagination-configuration-for-hubspot-rest-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1236" class="wp-image-1236 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-pagination-configuration-for-hubspot-rest-api.png" alt="JSON Source SSIS component pagination configuration for HubSpot REST API call" width="826" height="733" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-pagination-configuration-for-hubspot-rest-api.png 826w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-pagination-configuration-for-hubspot-rest-api-300x266.png 300w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-1236" class="wp-caption-text">JSON Source SSIS component pagination configuration for HubSpot API call</p></div></li>
</ol>
</div>
</li>
<li>Press &#8220;Preview&#8221; button to&#8230; well, obviously to preview the results 🙂
<div id="attachment_1306" style="width: 836px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-data-preview-for-hubspot-api-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1306" class="wp-image-1306 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-data-preview-for-hubspot-api-data.png" alt="JSON Source SSIS component data preview of HubSpot API call result" width="826" height="272" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-data-preview-for-hubspot-api-data.png 826w, https://zappysys.com/blog/wp-content/uploads/2017/06/ssis-json-source-data-preview-for-hubspot-api-data-300x99.png 300w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-1306" class="wp-caption-text">JSON Source SSIS component data preview of HubSpot API call result</p></div></li>
<li>Close &#8220;Data Preview&#8221; dialog and click &#8220;OK&#8221; button to save and close <em>JSON Source </em>component.</li>
<li>A dialog <em>Metadata Scan Options</em> should appear, to which you should respond &#8220;Ok&#8221; 🙂</li>
<li>Now you can connect <em>JSON Source</em> component with <em><em>OLE DB Destination:<br />
</em></em></p>
<div id="attachment_1243" style="width: 319px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/connect-ssis-json-source-for-hubspot-rest-api-with-ole-db-destination1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1243" class="wp-image-1243 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/connect-ssis-json-source-for-hubspot-rest-api-with-ole-db-destination1.png" alt="Connect JSON Source SSIS component with OLE DB Destination for HubSpot data." width="309" height="252" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/connect-ssis-json-source-for-hubspot-rest-api-with-ole-db-destination1.png 309w, https://zappysys.com/blog/wp-content/uploads/2017/06/connect-ssis-json-source-for-hubspot-rest-api-with-ole-db-destination1-300x245.png 300w" sizes="(max-width: 309px) 100vw, 309px" /></a><p id="caption-attachment-1243" class="wp-caption-text">Connect JSON Source SSIS component with OLE DB Destination for HubSpot data.</p></div></li>
<li>Now modify <em>OLE DB Destination </em>to have a connection to a <em>SQL Server</em> and point to a table, where you want contacts to be stored.</li>
<li>It&#8217;s time to map the columns of <em>JSON Source</em> with destination table columns. With your mouse simply connect corresponding columns or simply map <em>Input Column</em> with <em>Destination Column</em>. Press &#8220;OK&#8221; to close the window.
<div id="attachment_1244" style="width: 852px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/map-ssis-json-source-columns-with-hubspot-destination-table.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1244" class="wp-image-1244 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/map-ssis-json-source-columns-with-hubspot-destination-table.png" alt="Map JSON Source SSIS component columns with destination table columns you will store HubSpot data in" width="842" height="714" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/map-ssis-json-source-columns-with-hubspot-destination-table.png 842w, https://zappysys.com/blog/wp-content/uploads/2017/06/map-ssis-json-source-columns-with-hubspot-destination-table-300x254.png 300w" sizes="(max-width: 842px) 100vw, 842px" /></a><p id="caption-attachment-1244" class="wp-caption-text">Map JSON Source SSIS component columns with destination table columns you will store HubSpot data in</p></div></li>
<li>Finally, funtime! Press &#8220;F5&#8221; to execute the package. You should see a similar view as below. The number you see is the number of contacts were loaded from HubSpot API to your table:
<div id="attachment_1247" style="width: 1008px" class="wp-caption alignnone"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1247" class="wp-image-1247 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/how-to-get-hubspot-rest-api-data-with-ssis-final-result.png" alt="The result of getting HubSpot REST API data with SSIS" width="998" height="255" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/how-to-get-hubspot-rest-api-data-with-ssis-final-result.png 998w, https://zappysys.com/blog/wp-content/uploads/2017/06/how-to-get-hubspot-rest-api-data-with-ssis-final-result-300x77.png 300w" sizes="(max-width: 998px) 100vw, 998px" /><p id="caption-attachment-1247" class="wp-caption-text">The result of getting HubSpot API data with SSIS</p></div></li>
</ol>
<h2>API Rate Limit (Throttling)</h2>
<p><a href="https://developers.hubspot.com/apps/api_guidelines" target="_blank" rel="noopener">HubSpot places limits on using its API</a>. Basically, it doesn&#8217;t allow you to make endless number of calls per second. Also it has a ceiling for requests made per day. So if you have paging enabled in <em>JSON Source</em> component, it will make as many requests as it has to retrieve all data. And in this step you may get an error, telling that you exceeded calling rate limit of the API. To avoid that, simply go to the <em>Throttling</em> tab and set the amount of milliseconds component has to sleep after making each call:</p>
<div id="attachment_1294" style="width: 674px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-calls-throttling.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1294" class="wp-image-1294 size-full" src="//zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-calls-throttling.png" alt="HubSpot API calls throttling configuration" width="664" height="130" srcset="https://zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-calls-throttling.png 664w, https://zappysys.com/blog/wp-content/uploads/2017/06/hubspot-api-calls-throttling-300x59.png 300w" sizes="(max-width: 664px) 100vw, 664px" /></a><p id="caption-attachment-1294" class="wp-caption-text">HubSpot API calls throttling configuration</p></div>
<h2><span id="Making_things_Dynamic_eg_URL">Making things Dynamic (e.g. URL)</span></h2>
<p>The URL we used (<a href="https://api.hubapi.com/contacts/v1/lists/all/contacts/all">https://api.hubapi.com/contacts/v1/lists/all/contacts/all</a>) in addition to <pre class="crayon-plain-tag">count</pre> parameter, has others as well. Let&#8217;s say in some scenarios you want to fetch list memberships  for contacts, so you must include <pre class="crayon-plain-tag">&amp;showListMemberships=true</pre>  in the URL as well. To make things more generic, instead of using hard-coded <pre class="crayon-plain-tag">true</pre> value, you can use SSIS variables, then the URL will look like this:</p><pre class="crayon-plain-tag">https://api.hubapi.com/contacts/v1/lists/all/contacts/all?showListMemberships={{User::ShowMemberships}}</pre><p>
<h2>Common Errors</h2>
<p>For detailed instruction to fix common metadata related errors <a href="//zappysys.com/blog/handling-ssis-component-metadata-issues/" target="_blank" rel="noopener">read this article</a>.</p>
<p><strong>Truncation related error</strong></p>
<p>Most common error you may face when you run SSIS Package is truncation error. During design time only 300 rows scanned to detect datatype but at runtime you may extract far more records than 300. So its possible that you will get longer strings than initially expected. If you get error just copy that to notepad and read error carefully. It will explain the steps needed to fix the problem. Basically you can edit Columns on JSON Source UI &gt; Change Data Length or Datatype (if you need more than 4000 chars change to the type to DT_NTEXT and click on Column Name cell to save change). After you edit default settings then make sure to check Lock option (found all on the right side in same row).</p>
<p><strong>Authentication related error (happens when you run package from SQL Job Agent)</strong></p>
<p>So many times when you run from Visual Studio it works fine but when you deploy to Production and run from SQL Job it fails. If this is your issue then check you passing Token (i.e. Password Property of HTTP connection) using some sort of parameter approach (e.g. from command line or from config file). By default password is encrypted using your account so when you run it from SQL Job it will fail to decrypt it. See more on <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">Package Protection Level</a>.</p>
<h2><a name="deployment"></a>Deployment to Production</h2>
<p>When you are ready to deploy the package to Production consider passing Refresh Tokens and other sensitive data as passwords via SSIS parameters. In this way you don’t face authentication related error described in above section. See more on <a href="https://docs.microsoft.com/en-us/sql/integration-services/security/access-control-for-sensitive-data-in-packages" target="_blank" rel="noopener">Package Protection Level</a>.</p>
<h2>Download Sample Package</h2>
<p>Be sure to download a <a href="//zappysys.com/blog/wp-content/uploads/2017/06/Get-data-from-HubSpot-API-with-SSIS.zip">sample SQL Server 2012 SSIS package</a>, in case you encounter problems that you can&#8217;t go through in the step-by-step part.</p>
<div class="su-note"  style="border-color:#e5e5c6;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#ffffe0;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Once you open the package, you won&#8217;t be able to run it immediately, but don&#8217;t panic. Firstly, it&#8217;s because you have a different SQL destination table. Secondly, you won&#8217;t see any sensitive data in the package, like tokens. Therefore you will have to perform OAuth authentication process to get those. So fix errors one by one and you are good to go. </div></div>
<h2>Conclusion</h2>
<p>In this article we learned how to call HubSpot API <a href="http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069" target="_blank" rel="noopener">RESTful</a> method and retrieve all contacts. Actually, HubSpot API consists of many small APIs and we used <a href="https://developers.hubspot.com/docs/methods/contacts/contacts-overview" target="_blank" rel="noopener">Contacts API</a> method particularly. If you need anything else than simply retrieving the contacts of your account, delve into the vastness of <a href="https://developers.hubspot.com/docs" target="_blank" rel="noopener">HubSpot API methods</a>!</p>
<p>Also it&#8217;s worth mentioning that <em>JSON Source</em> and <em>OAuth Connection </em>SSIS components saved us some valuable time, because we avoided using default SSIS <em>Script Component</em> and doing all the hard work ourselves.</p>
<h2>Keywords</h2>
<p>How to fetch data from HubSpot API | Pull data from HubSpot API into SQL Server | Call HubSpot API with SSIS | Sync HubSpot data to SQL Server | HubSpot data integration with SQL Server database | Load data from HubSpot REST API using SSIS</p>
<p>The post <a href="https://zappysys.com/blog/get-data-from-hubspot-api-with-ssis/">How to get data from HubSpot API with 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 call eBay REST API in SQL Server with SSIS</title>
		<link>https://zappysys.com/blog/how-to-call-ebay-rest-api-using-ssis-oauth-connection/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 07 Feb 2017 03:36:07 +0000</pubDate>
				<category><![CDATA[REST API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[ebay api]]></category>
		<category><![CDATA[oauth2]]></category>
		<category><![CDATA[SQL Server Integration Services]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[ssis json source]]></category>
		<category><![CDATA[ssis oauth connection]]></category>
		<category><![CDATA[ssis rest api task]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=981</guid>

					<description><![CDATA[<p> Introduction eBay recently launched brand new REST API with OAuth 2.0 support. This article will explain you how to call eBay REST API using SSIS to automate eBay operations (e.g. Buy/Sell) using SSIS REST API Integration Connectors / OAuth Connection Manager. This article assumes that you have basic knowledge of SSIS (SQL Server Integration Services). [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/how-to-call-ebay-rest-api-using-ssis-oauth-connection/">How to call eBay REST API in SQL Server with 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="//zappysys.com/blog/wp-content/uploads/2017/02/ebay-api-integration.png"><img loading="lazy" decoding="async" class=" wp-image-1626 alignleft" src="//zappysys.com/blog/wp-content/uploads/2017/02/ebay-api-integration.png" alt="" width="154" height="154" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ebay-api-integration.png 250w, https://zappysys.com/blog/wp-content/uploads/2017/02/ebay-api-integration-150x150.png 150w" sizes="(max-width: 154px) 100vw, 154px" /></a>eBay recently launched brand new REST API with OAuth 2.0 support. This article will explain you how to <em>call eBay REST API using SSIS</em> to automate eBay operations (e.g. Buy/Sell) using <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-integration-pack/" target="_blank" rel="noopener">SSIS REST API Integration Connectors</a> / <a href="https://zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a>.</p>
<p>This article assumes that you have basic knowledge of SSIS (SQL Server Integration Services). We will use drag and drop approach without coding to do <em>eBay REST API integration</em>. We will use following custom tasks/connectors from <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a></p>
<p><a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> REST API Connectors can be used to consume/manage eBay data using API calls. Following connectors will be used in this article.</p>
<div class="su-table su-table-alternate">
<table>
<tbody>
<tr>
<td width="36"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-rest-api-web-service-task.png" alt="Custom SSIS Tasks - Call REST API Webservice (GET, POST, DELETE etc)" width="32" /></td>
<td><u><a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a></u></td>
</tr>
<tr>
<td width="36"><img decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/oauth-connection/ssis-oauth-connection-manager.png" alt="SSIS OAuth Connection Manager" width="32" /></td>
<td><a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener">OAuth Connection Manager</a></td>
</tr>
<tr>
<td width="36"><img decoding="async" src="//zappysys.com/images/SSIS-PowerPack/SSIS-Json-Source-Adapter.png" alt="Custom SSIS Components - JSON Source (File, REST, OData)" width="32" /></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source (File, REST, OData)</a></td>
</tr>
</tbody>
</table>
</div>
<h2>Test Ebay API using Online API Testing Tool</h2>
<p>Before you can dig deep down we suggest you to try few API calls using ebay online testing tool. Here is an example api call using their Online Testing Tool.</p>
<p>For example visit below URL to try sample Search API call.</p><pre class="crayon-plain-tag">https://developer.ebay.com/my/api_test_tool?index=0&amp;env=production&amp;api=browse&amp;call=item_summary_search__GET&amp;variation=json</pre><p>
<div id="attachment_6519" style="width: 1187px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6519" class="wp-image-6519 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool.png" alt="Testing Ebay REST API using Online Tool" width="1177" height="770" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool.png 1177w, https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool-300x196.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool-768x502.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/02/testing-ebay-rest-api-tool-1024x670.png 1024w" sizes="(max-width: 1177px) 100vw, 1177px" /></a><p id="caption-attachment-6519" class="wp-caption-text">Testing Ebay REST API using Online Tool</p></div>
<p>&nbsp;</p>
<h2>Call eBay API using SSIS &#8211; Create new inventory item</h2>
<p>Now lets look at how to make simple eBay REST API call using SSIS. For demo purpose we will use Sandbox API rather than production.</p>
<ol>
<li>First download and install <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack from here</a>.</li>
<li>Create new SSIS Project and open SSIS Package</li>
<li>Drag new ZS REST API Task from SSIS Toolbox on control flow designer</li>
<li>Rename ZS REST API Task to <strong>Create eBay inventory item-1</strong>. Double click the task to configure it.</li>
<li>Select Request mode to [Url from Connection]</li>
<li>Select ZS-OAUTH connection type from connection dropdown.</li>
<li>On OAuth connection. Select <strong>eBay Sandbox</strong> from provider dropdown.</li>
<li>Enter App ID in Client ID field (<a href="http://developer.ebay.com/Devzone/rest/ebay-rest/content/oauth-gen-user-token.html#Getting4" target="_blank" rel="noopener">Obtained from here</a>)</li>
<li>Enter Cert ID in Client Secret field  (<a href="http://developer.ebay.com/Devzone/rest/ebay-rest/content/oauth-gen-user-token.html#Getting4" target="_blank" rel="noopener">Obtained from here</a>)</li>
<li>Select desired Scopes or leave it blank to use default scopes. For this example we need following two scopes<br />
https://api.ebay.com/oauth/api_scope/sell.inventory<br />
https://api.ebay.com/oauth/api_scope/sell.inventory.readonly</li>
<li>Click on Advanced Tab. Enter <strong>RuName</strong> in the Return URL field. Don&#8217;t worry if your RuName doesn&#8217;t look like URL 🙂 (<a href="http://developer.ebay.com/Devzone/rest/ebay-rest/content/oauth-gen-user-token.html#Getting4" target="_blank" rel="noopener">Click here to learn how to get RuName</a> &#8211; Scroll to <strong>Getting the RuName value</strong>)</li>
<li>Now click on first tab again. Click <strong>Generate token</strong> button. When prompted login using Sandbox User Account (<a href="http://www.developer.ebay.com/DevZone/sandboxuser/" target="_blank" rel="noopener">Click here to create test user</a> for Sandbox).<br />
<strong>NOTE:</strong> <span style="text-decoration: underline;">Production account or developer account wont work when you login for eBay Sandbox API Token</span></li>
<li>Click Accept button after login. If everything goes well you will see two tokens populated on your main screen (Access Token and Refresh Token). You will get prompt to save tokens to some backup file&#8230; Do that so same tokens can be used if you wish to deploy JOB to another machine.</li>
<li>Click Test to validate connection. Click OK to save.
<div id="attachment_993" style="width: 731px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-connection-ebay-sandbox-production-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-993" class="size-full wp-image-993" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-connection-ebay-sandbox-production-api.png" alt="SSIS OAuth Connection Manager - Connect to eBay Sandbox API" width="721" height="708" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-connection-ebay-sandbox-production-api.png 721w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-oauth-connection-ebay-sandbox-production-api-300x295.png 300w" sizes="(max-width: 721px) 100vw, 721px" /></a><p id="caption-attachment-993" class="wp-caption-text">SSIS OAuth Connection Manager &#8211; Connect to eBay Sandbox API</p></div></li>
<li>Now once you close connection you are back to REST API Task</li>
<li>Enter following URL to <a href="http://developer.ebay.com/devzone/rest/api-ref/inventory/inventory_item-sku__put.html" target="_blank" rel="noopener">create or new eBay inventory item</a> using PUT. Last part of following URL is ID we want to create<br />
<pre class="crayon-plain-tag">https://api.sandbox.ebay.com/sell/inventory/v1/inventory_item/GP-Cam-01</pre>
</li>
<li>Select Method <strong>PUT</strong> from dropdown</li>
<li>Click Edit for Request Body. Enter following data for our sample product<br />
<pre class="crayon-plain-tag">{
	"availability" : {
		"shipToLocationAvailability" : {
			"quantity" : 50
		}
	},
	"condition" : "NEW",
	"product" : {
		"title" : "GoPro Hero4 Helmet Cam",
		"description" : "New GoPro Hero4 Helmet Cam. Unopened box.",
		"aspects" : {
			"Brand" : ["GoPro"],
			"Type" : ["Helmet/Action"],
			"Storage Type" : ["Removable"],
			"Recording Definition" : ["High Definition"],
			"Media Format" : ["Flash Drive (SSD)"],
			"Optical Zoom" : ["10x"]
		},
		"imageUrls" : [
			"http://i.ebayimg.com/images/i/182196556219-0-1/s-l1000.jpg",
			"http://i.ebayimg.com/images/i/182196556219-0-1/s-l1001.jpg",
			"http://i.ebayimg.com/images/i/182196556219-0-1/s-l1002.jpg"
		]
	}
}</pre>
</li>
<li>Change Body content type to JSON from dropdown</li>
<li>Click on [Raw Edit] button in Headers grid toolbar. Enter following headers and click OK.<br />
<pre class="crayon-plain-tag">Content-Language: en-US
Accept: application/json</pre>
&nbsp;</li>
<li>Click Test Request/Response &#8211; If you get success that means product got created.<a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-rest-api-create-new-inventory-item-using-put.png"><img loading="lazy" decoding="async" class="size-full wp-image-994" src="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-rest-api-create-new-inventory-item-using-put.png" alt="SSIS Rest API Task - Call eBay REST API to create new inventory item" width="604" height="604" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-rest-api-create-new-inventory-item-using-put.png 604w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-rest-api-create-new-inventory-item-using-put-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-rest-api-create-new-inventory-item-using-put-300x300.png 300w" sizes="(max-width: 604px) 100vw, 604px" /></a></li>
<li>You can create more products by simply changing SKU in URL and name/description in Body. Click Test to execute API call.</li>
</ol>
<h2>Read data from eBay and load into SQL Server using SSIS JSON Source</h2>
<p>Now lets look at how to consume eBay REST API and load data into SQL Server. For this you can use <a href="//zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source (File, REST API)</a>. For this demo we will <a href="https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search" target="_blank" rel="noopener">Call eBay Search API</a> . If you want to explore other API then <a href="https://developer.ebay.com/api-docs/buy/browse/resources/methods" target="_blank" rel="noopener">check this page</a>. Here is</p>
<ol>
<li>Go to Data flow tab</li>
<li>Drag and drop ZS JSON Source from SSIS Toolbox</li>
<li>Double click to configure it.</li>
<li>Enter API URL like below. We added Search parameter and limit parameter (Max rows per response). Refer to API Help page to know more about other available parameters.<br />
<pre class="crayon-plain-tag">https://api.sandbox.ebay.com/buy/browse/v1/item_summary/search?q=phone&amp;amp;limit=100</pre>
</li>
<li>Check Use Credentials option.</li>
<li>Select ZS-OAUTH connection or Create New (See previous section to create new one)</li>
<li>Select Filter (Look for Array Icon and select that node). For example if you calling search API then  enter or select  <pre class="crayon-plain-tag">$.itemSummaries[*]</pre>  like below.
<div id="attachment_996" style="width: 849px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2017/02/ssis-get-ebay-inventory-items-rest-api-call-oauth.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-996" class="wp-image-996 size-full" src="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-get-ebay-inventory-items-rest-api-call-oauth.png" alt="SSIS JSON Source - Get data from eBay REST API (Use OAuth Connection)" width="839" height="767" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-get-ebay-inventory-items-rest-api-call-oauth.png 839w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-get-ebay-inventory-items-rest-api-call-oauth-300x274.png 300w" sizes="(max-width: 839px) 100vw, 839px" /></a><p id="caption-attachment-996" class="wp-caption-text">SSIS JSON Source &#8211; Get data from eBay REST API (Use OAuth Connection)</p></div></li>
<li>Now click on pagination tab and enter <pre class="crayon-plain-tag">$.next</pre>  expression for next link attribute as below. This will enable pagination (It will keep reading in 100 rows per page until last page reached &#8211; Empty  recordset)
<div id="attachment_6517" style="width: 646px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-api-pagination-for-search-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-6517" class="size-full wp-image-6517" src="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-api-pagination-for-search-api.png" alt="Ebay REST API Pagination (Search API Example)" width="636" height="582" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-api-pagination-for-search-api.png 636w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-api-pagination-for-search-api-300x275.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></a><p id="caption-attachment-6517" class="wp-caption-text">Ebay REST API Pagination (Search API Example)</p></div></li>
<li>That&#8217;s it, now <strong>click Preview</strong> to see data</li>
<li>Once all looking good you can click OK to save JSON Source.</li>
<li>In Next Section we will see how to load Ebay Data into SQL Server.</li>
</ol>
<h2>Loading eBay 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>Pagination for eBay REST API Calls</h2>
<p>In previous example we saw REST API Pagination using Next Link approach but some API may not use same approach in that case <a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/">refer to this link</a>.  We looked at Next Link approach in previous section, you can also use Method #2 (URL parameter  &#8211; Offset) but Next Link approach is more simpler.</p>
<h2>Calling eBay XML format API &#8211; Finding / Trading / Shopping API</h2>
<p>eBay converted most of their APIs to JSON format to use OAuth 2.0 standard but there few APIs still there which are not OAuth 2.0 standard. These includes eBay Trading API, eBay Finding API, eBay Shopping API. They all are still in XML format. Below section describe how to call these API. Use <a href="https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx" target="_blank" rel="noopener">eBay API Test tool here</a> to generate desired Request Body and Headers.</p>
<p>Now let&#8217;s look at an example to call eBay XML API (GetItem from Trading API). To support special case like eBay API ZappySys introduced OAuth connection property called CustomAuthHeader in <strong>v2.6.7 or higher</strong> (Only found in Properties grid view).</p>
<ol>
<li>Right click on OAuth connection manager icon &gt; Click Properties &gt; Set <strong>CustomAuthHeader</strong> to <strong>X-EBAY-API-IAF-TOKEN</strong><br />
<a href="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-xml-api-trading-finding-shopping-using-oauth-token.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2634" src="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-xml-api-trading-finding-shopping-using-oauth-token.png" alt="" width="615" height="230" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-xml-api-trading-finding-shopping-using-oauth-token.png 615w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-ebay-xml-api-trading-finding-shopping-using-oauth-token-300x112.png 300w" sizes="(max-width: 615px) 100vw, 615px" /></a></li>
<li>Now drag ZS REST API Task from Control flow SSIS Toolbox</li>
<li>Set Properties like below
<ol>
<li>Set URL as below (Sandbox Url is different than Production)<br />
<pre class="crayon-plain-tag">https://api.sandbox.ebay.com/ws/api.dll</pre>
</li>
<li>Set Body As (this was obtained from  <a href="https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx" target="_blank" rel="noopener">eBay API Test tool here</a> )<br />
<pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"&gt;
	&lt;ErrorLanguage&gt;en_US&lt;/ErrorLanguage&gt;
	&lt;WarningLevel&gt;High&lt;/WarningLevel&gt;
      &lt;!--Enter an ItemID--&gt;
  &lt;ItemID&gt;1234&lt;/ItemID&gt;
&lt;/GetItemRequest&gt;</pre>
</li>
<li>Set Headers as below (Click on Raw Edit Button and paste below heades). Again these header were also copied from <a href="https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx" target="_blank" rel="noopener">eBay API Test tool here</a> . Notice that API function name is included in the header. Also site id and compatibility level required.<br />
<pre class="crayon-plain-tag">X-EBAY-API-CALL-NAME: GetItem
X-EBAY-API-SITEID: 0
X-EBAY-API-COMPATIBILITY-LEVEL: 967</pre>
</li>
<li>Now click OK to get response. If things working you will see some valid XML.
<div id="attachment_2635" style="width: 1059px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2635" class="size-full wp-image-2635" src="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token.png" alt="Call eBay XML API using SSIS REST API Task (eBay Trading API, Shopping API, Finding API using OAuth Token)" width="1049" height="762" srcset="https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token.png 1049w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token-300x218.png 300w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token-768x558.png 768w, https://zappysys.com/blog/wp-content/uploads/2017/02/ssis-call-ebay-trading-api-finding-shopping-xml-format-using-oauth-token-1024x744.png 1024w" sizes="(max-width: 1049px) 100vw, 1049px" /></a><p id="caption-attachment-2635" class="wp-caption-text">Call eBay XML API using SSIS REST API Task (eBay Trading API, Shopping API, Finding API using OAuth Token)</p></div></li>
</ol>
</li>
</ol>
<h2>User Token vs Application Token</h2>
<p>Any time you call eBay API you have to supply token. eBay OAuth supports two types of token. In this article we used User Token. If you wish to use Application Token then you have to use OAuth Client Credentials grant. <a href="https://zappysys.zendesk.com/hc/en-us/articles/360008704413-How-to-call-API-in-SSIS-with-OAuth-2-0-Client-Credentials-Grant-Type" target="_blank" rel="noopener">See this article</a></p>
<p><strong>Difference between eBay Application Token vs User Token</strong></p>
<ol>
<li>Application Token<br />
&#8211; Do not require user login<br />
&#8211; Use this token if you need to perform basic operations which are supported by following permission   https://api.ebay.com/oauth/api_scope</li>
<li>User Token<br />
&#8211; Requires one time user login to create token and then refreshes automatically without login prompt (if you using SSIS PowerPack)<br />
&#8211; Use this token if you need higher privileges behalf of actual use for update/write data using API call</li>
</ol>
<p>Use Application token when you want to perform readonly operations and you don&#8217;t need higher privileges (such as admin access). Certain eBay API calls only possible if you supply user token.</p>
<h2><span id="POST_data_to_Xero_Insert_or_Update">POST data to Ebay (Insert or Update)</span></h2>
<p>In previous section we have seen how to read data from ebay. Now let’s look at how to write data to ebay.</p>
<p>There are two ways you can achieve this.</p>
<ol>
<li>Use <a href="//zappysys.com/products/ssis-powerpack/ssis-web-api-destination-connector/" target="_blank" rel="noopener">Web API Destination</a> in Data Flow</li>
<li>Use <a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a> in Control Flow</li>
</ol>
<p>Read this article to learn more about <a href="//zappysys.com/blog/http-post-in-ssis-send-data-to-web-api-url-json-xml/" target="_blank" rel="noopener">API POST using SSIS</a></p>
<h3><span id="Using_SSIS_Web_API_Task_Write_data_from_SQL_Server_to_Xero">Using SSIS Web API Task (Write data from SQL Server to ebay)</span></h3>
<h3><img decoding="async" src="https://i0.wp.com/zappysys.com/onlinehelp/ssis-powerpack/scr/images/web-api-destination/ssis-web-api-destination-post-json-to-rest-api-url.png?resize=503%2C403" alt="SSIS Web API Destination - POST JSON to REST API Endpoint, Create / Update records" /></h3>
<h3><span id="Using_REST_API_Task_to_POST_data_to_Xero">Using REST API Task to POST data to ebay</span></h3>
<p>If you have JSON/XML data already prepared and if you like to POST it to ebay API then REST API Task would be easy to use.</p>
<p>REST API Task Body can be direct string, variable (e.g. {{User::varSomeData}} or <a href="https://zappysys.com/blog/rest-api-file-upload-using-ssis-multi-part-post/" target="_blank" rel="noopener">Body can come from File </a></p>
<div id="attachment_1616" class="wp-caption alignnone">
<p><a href="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png"><img loading="lazy" decoding="async" class="size-full wp-image-1616" style="border: 0px; max-width: 100%; height: auto; box-shadow: rgba(0, 0, 0, 0.176) 0px 1px 2px;" src="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?resize=720%2C503" sizes="(max-width: 720px) 100vw, 720px" srcset="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?w=862 862w, https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?resize=300%2C210 300w, https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?resize=768%2C536 768w" alt="SSIS REST API Task - POST data to Xero (Create contacts)" width="702" height="490" data-attachment-id="1616" data-permalink="//zappysys.com/blog/reading-loading-data-in-xero-sql-server-ssis/ssis-post-data-xero-api-create-contacts-example/#main" data-orig-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?fit=862%2C602" data-orig-size="862,602" 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-post-data-xero-api-create-contacts-example" data-image-description="&lt;p&gt;SSIS REST API Task – POST data to Xero (Create contacts)&lt;/p&gt; " data-medium-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?fit=300%2C210" data-large-file="https://i2.wp.com/zappysys.com/blog/wp-content/uploads/2017/07/ssis-post-data-xero-api-create-contacts-example.png?fit=720%2C503" /></a></p>
<p class="wp-caption-text">SSIS REST API Task – POST data to ebay (Create contacts)</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>Conclusion</h2>
<p>REST API integration typically requires coding and good understanding of protocol such as OAuth. SSIS PowerPack REST API connectors and OAuth Connection provides easy to use interface with many options to integrate virtually any API including eBay REST API inside your SQL Server Environment without any coding. Try <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> yourself see what is possible.</p>
<p>The post <a href="https://zappysys.com/blog/how-to-call-ebay-rest-api-using-ssis-oauth-connection/">How to call eBay REST API in SQL Server with SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to call Amazon MWS API using SSIS</title>
		<link>https://zappysys.com/blog/call-amazon-mws-api-using-ssis-marketplace-web-service/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 15 Oct 2016 04:42:21 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS CSV Source]]></category>
		<category><![CDATA[SSIS XML Source (File / SOAP)]]></category>
		<category><![CDATA[Amazon MWS]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[looping]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[ssis xml source]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=822</guid>

					<description><![CDATA[<p>Introduction In this post you will learn how to call Amazon MWS API (Amazon Marketplace Web Service) or Amazon Product Advertising API using SSIS PowerPack. Using drag and drop approach you can consume data from Amazon MWS XML Web service. In this post we will use ZappySys XML Source connector to read data from Amazon MWS [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/call-amazon-mws-api-using-ssis-marketplace-web-service/">How to call Amazon MWS API using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<div class="su-note"  style="border-color:#e2dec9;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:#fcf8e3;border-color:#ffffff;color:#8a6d3b;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">
<strong><span style="vertical-align: text-bottom;font-size: 0.86em;">⚠️</span> Deprecation Notice: MWS API is deprecated</strong><br />
Amazon&#8217;s MWS (Marketplace Web Service) is being deprecated and <strong>replaced by the newer AWS Selling Partner API (SP-API).</strong> For a more robust and secure integration, we <strong>recommend</strong> using our <strong><a href="/api/integration-hub/amazon-selling-partner-connector/">AWS Selling Partner (SP-API) Connector</a>.</strong> As Amazon is phasing out MWS functionality and eventually plans to fully deprecate it.<br />
</div></div>
<p><a href="//zappysys.com/blog/wp-content/uploads/2016/10/amazon-mws-api-integration.png"><img loading="lazy" decoding="async" class="alignleft wp-image-1632" src="//zappysys.com/blog/wp-content/uploads/2016/10/amazon-mws-api-integration.png" alt="" width="120" height="120" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/amazon-mws-api-integration.png 505w, https://zappysys.com/blog/wp-content/uploads/2016/10/amazon-mws-api-integration-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2016/10/amazon-mws-api-integration-300x300.png 300w" sizes="(max-width: 120px) 100vw, 120px" /></a>In this post you will learn how to <em>call Amazon MWS API</em> (<a href="https://developer.amazonservices.com/" target="_blank" rel="noopener">Amazon Marketplace Web Service</a>) or <a href="http://docs.aws.amazon.com/AWSECommerceService/latest/GSG/Welcome.html" target="_blank" rel="noopener">Amazon Product Advertising API</a> using <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a>.</p>
<p>Using drag and drop approach you can <em>consume data from Amazon MWS XML Web service.</em> In this post we will use <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZappySys XML Source connector</a> to read data from Amazon MWS API and load into SQL Server. We will also use <a href="//zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task</a> to call any API from Marketplace Web service and save output into Variable.</p>
<h2>Prerequisites</h2>
<p>This post assumes following things</p>
<ol>
<li>Basic knowledge of SSIS and XML format.</li>
<li>Amazon MWS Account and and valid AWSAccessKeyId and Secret Key to call Amazon MWS API <a href="https://zappysys.com/blog/import-amazon-mws-data-power-bi/#Obtain_MWS_API_Access_Key_Secret_and_Seller_ID" target="_blank" rel="noopener">(How to obtain Key / Secret and SellerId ? )</a>.</li>
<li>You have tested few API calls using <a href="https://mws.amazonservices.com/scratchpad/index.html" target="_blank" rel="noopener">Amazon MWS Scratchpad</a> this will give you idea about various API you can call and parameters you need to pass.</li>
</ol>
<h2>Testing MWS Requests using ScratchPad</h2>
<p>Very first step we recommend before you call MWS API in SSIS is to get familiar with <a href="https://mws.amazonservices.com/scratchpad/index.html" target="_blank" rel="noopener">Amazon MWS Scratchpad</a> tool. Check this article for <a href="https://zappysys.com/blog/import-amazon-mws-data-power-bi/#About_Amazon_MWS_API">detailed steps</a>.  You can also use <a href="https://zappysys.com/blog/how-to-use-fiddler-to-analyze-http-web-requests/">Fiddler</a> to debug some requests.</p>
<div id="attachment_4847" style="width: 933px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4847" class="size-full wp-image-4847" src="https://zappysys.com/blog/wp-content/uploads/2018/09/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png" alt="Calling Amazon MWS API in Scratchpad Testing Tool (Response Details Tab) - ListMatchingProducts Example" width="923" height="527" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/amazon-mws-api-response-scratchpad-listmatchingproducts-example.png 923w, https://zappysys.com/blog/wp-content/uploads/2018/09/amazon-mws-api-response-scratchpad-listmatchingproducts-example-300x171.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/09/amazon-mws-api-response-scratchpad-listmatchingproducts-example-768x439.png 768w" sizes="(max-width: 923px) 100vw, 923px" /></a><p id="caption-attachment-4847" class="wp-caption-text">Calling Amazon MWS API in Scratchpad Testing Tool (Response Details Tab) &#8211; ListMatchingProducts Example</p></div>
<h2>Call Amazon MWS API using SSIS</h2>
<p>To consume data from any XML Source (File, SOAP Web Service or XML API) you can use  <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZappySys XML Source<br />
connector.</a> or <a href="//zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">REST API Task.</a> In below example you will see how to call Amazon MWS API and save output into Variable. With this approach you can call any API (GET / POST / DELETE / PUT)</p>
<ol>
<li>Download and Install SSIS PowerPack</li>
<li>Create test package</li>
<li>From SSIS toolbox drag <a href="//zappysys.com/blog/call-rest-api-using-ssis-web-service-task/" target="_blank" rel="noopener">ZS REST API Task</a>  and double click on the task to configure it</li>
<li>Select Request URL Access Mode = [Url from Connection]</li>
<li>Enter URL as below<br />
<pre class="crayon-plain-tag">https://mws.amazonservices.com/Orders/2013-09-01</pre>
In above URL<br />
** mws.amazonservices.com =&gt; This is your endpoint. If you are not in USA then <a href="http://docs.developer.amazonservices.com/en_UK/dev_guide/DG_Endpoints.html" target="_blank" rel="noopener">Click here</a> to find correct endpoint<br />
** /Orders =&gt; That&#8217;s your API you want to call<br />
** /2013-09-01 =&gt; That&#8217;s your API version (You have to add this same version in your POST Body too (see next section).</li>
<li>In Select Url Connection dropdown select New OAUTH connection option.</li>
<li>When prompted on OAuth connection UI select Provider=Amazon MWS, Enter AWSAccessKey and Secret key and Click OK (If you have MWSAuthToken then enter in Access Token field else leave it empty). Do not test because it may not work yet.
<div id="attachment_825" style="width: 685px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-marketplace-web-service-connection-manager.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-825" class="size-full wp-image-825" src="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-marketplace-web-service-connection-manager.png" alt="SSIS OAuth Connection - Call Amazon MWS API (Marketplace Web service API) " width="675" height="475" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-marketplace-web-service-connection-manager.png 675w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-marketplace-web-service-connection-manager-300x211.png 300w" sizes="(max-width: 675px) 100vw, 675px" /></a><p id="caption-attachment-825" class="wp-caption-text">SSIS OAuth Connection &#8211; Call Amazon MWS API (Marketplace Web service API)</p></div></li>
<li>Another Setting you may turn on is Retry Handling. This allows to over come ThresholdLimitReached error when we <a href="https://docs.developer.amazonservices.com/en_UK/dev_guide/DG_Throttling.html" target="_blank" rel="noopener">call API too fast</a>.
<div id="attachment_7156" style="width: 599px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7156" class="size-full wp-image-7156" src="https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection.png" alt="Retry Options" width="589" height="429" srcset="https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection.png 589w, https://zappysys.com/blog/wp-content/uploads/2018/09/http-retry-settings-oauth-connection-300x219.png 300w" sizes="(max-width: 589px) 100vw, 589px" /></a><p id="caption-attachment-7156" class="wp-caption-text">Retry Options</p></div></li>
<li>Now select Method=POST, and in the body enter following<br />
<pre class="crayon-plain-tag">Action=GetServiceStatus&amp;SellerId=A77XXXXXXX&amp;Version=2013-09-01</pre>
If your API requires pagination (more than 100 records from response) then refer next section (Sample Package). In the case of Pagination your second request may look like below<br />
<pre class="crayon-plain-tag">Action=YourActionNameWithNextToken&amp;SellerId=A77XXXXXXX&amp;Version=2013-09-01&amp;NextToken={{User::vNextToken,FUN_URLENC}}</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> Enter all required parameters in the following format, as shown below. All values need to be URL-encoded. If you use SSIS variable, use it along with <strong>FUN_URLENC</strong> format specifier, e.g. <strong>{{User::myVariable,FUN_URLENC}}</strong>. If you use a hard-coded value, and not sure if it is URL-encoded, then encode it with the same <strong>FUN_URLENC</strong> format specifier/function, e.g. <strong>&lt;&lt;myValue,FUN_URLENC&gt;&gt;</strong>. Always check if SSIS configuration matches the one you see in <em>MWS ScratchPad Request</em> <em>Details</em>.<br />
<strong>Format:</strong><br />
<code>param1=value1&amp;param2=&lt;&lt;value2,FUN_URLENC&gt;&gt;&amp;param3={{User::myVar,FUN_URLENC}}</code></div></div></li>
<li>Now click Test and see content in the Preview window.
<div id="attachment_826" style="width: 786px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-api-marketplace-webservice-use-rest-api-task.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-826" class="size-full wp-image-826" src="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-api-marketplace-webservice-use-rest-api-task.png" alt="SSIS REST API Task - Call Amazon MWS API - Get XML data save into SSIS variable" width="776" height="652" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-api-marketplace-webservice-use-rest-api-task.png 776w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-api-marketplace-webservice-use-rest-api-task-300x252.png 300w" sizes="(max-width: 776px) 100vw, 776px" /></a><p id="caption-attachment-826" class="wp-caption-text">SSIS REST API Task &#8211; Call Amazon MWS API &#8211; Get XML data save into SSIS variable</p></div></li>
<li>If you wish to save response data into SSIS variable then goto response Tab and check save option and select variable name.</li>
</ol>
<h2>Amazon MWS API Pagination</h2>
<p>Many Amazon MWS API calls by default don&#8217;t return all records (Explained <a href="https://docs.developer.amazonservices.com/en_US/dev_guide/DG_NextToken.html" target="_blank" rel="noopener">here</a>). Rather than returning all rows you may get partial response (e.g. Max 50 or 100 rows). If you want to get all records then you have to use NextToken  found in your XML. For API which requires pagination, in that case your POST body may be different for 2nd or higher requests. Notice how we changed Action and appended NextToken=xxxxxxxxxxx in the second request. Also notice we used encoded token (URL encoded). This is very important because as per Amazon Specs this value has to be Url Encoded.</p>
<p>We also documented similar use case of <a href="https://zappysys.com/blog/import-amazon-mws-data-power-bi/#Using_Pagination_in_Amazon_MWS_API_calls" target="_blank" rel="noopener">Amazon MWS Pagination for Power BI (Check this one)</a> its mostly same setup except 2-3 properties might be named different way.</p>
<p>Now lets look at sample request / response for paginated MWS requests (For clarity we have removed many common Parameters which are automatically added at runtime e.g. Signature, Timestamp). We use <a href="https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_ListOrders.html" target="_blank" rel="noopener">ListOrders</a> (First Request) and <a href="https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_ListOrdersByNextToken.html" target="_blank" rel="noopener">ListOrderByNextToken</a> (Second+ requests)</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: Most of Amazon MWS API calls are heavily throttled means you cannot call more than X calls per minute or hour. So Refer to <a href="https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Throttling.html" target="_blank" rel="noopener">Throttling Limits</a> for each API Endpoint.</div></div>
<p><strong>First Request</strong></p><pre class="crayon-plain-tag">POST https://mws.amazonservices.com/Orders/2013-09-01

Action=ListOrders&amp;SellerId=A10zzzzzzz&amp;CreatedAfter=2018-09-01T04%3A00%3A00Z</pre><p>
<strong>First Response</strong></p><pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;ListOrdersResponse xmlns="https://mws.amazonservices.com/
    Orders/2013-09-01"&gt;
    &lt;ListOrdersResult&gt;
        &lt;NextToken&gt;2YgYW55IxxxxxxxxxxxxVyZS4=&lt;/NextToken&gt;
        &lt;LastUpdatedBefore&gt;2017-02-25T18%3A10%3A21.687Z&lt;/LastUpdatedBefore&gt;
        &lt;Orders&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
        &lt;/Orders&gt;
    &lt;/ListOrdersResult&gt;
&lt;/ListOrdersResponse&gt;</pre><p>
&nbsp;</p>
<p><strong>Second Request or higher (MWS API with Pagination using NextToken)</strong></p><pre class="crayon-plain-tag">POST https://mws.amazonservices.com/Orders/2013-09-01

Action=ListOrdersByNextToken&amp;SellerId=A10zzzzzzz&amp;CreatedAfter=2018-09-01T04%3A00%3A00Z&amp;NextToken=YOUR_ENCODED_TOKEN_FROM_PREV_REQUEST</pre><p>
<strong>Second or higher Response</strong></p><pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;ListOrdersByNextTokenResponse xmlns="https://mws.amazonservices.com/
    Orders/2013-09-01"&gt;
    &lt;ListOrdersByNextTokenResult&gt;
        &lt;NextToken&gt;2YgYW55IxxxxxxxxxxxxVyZS4=&lt;/NextToken&gt;
        &lt;LastUpdatedBefore&gt;2017-02-25T18%3A10%3A21.687Z&lt;/LastUpdatedBefore&gt;
        &lt;Orders&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
        &lt;/Orders&gt;
    &lt;/ListOrdersResult&gt;
&lt;/ListOrdersResponse&gt;</pre><p>
<h3>Sample SSIS Package</h3>
<p>If you want to see complete working package for pagination pattern then <a href="https://zappysys.com/blog/wp-content/uploads/2016/10/Amazon_MWS_API_With_LoopEasy_2012.zip" target="_blank" rel="noopener">download from here</a>. Change AccessKey, SecretKey, SellerID and Path as needed to make this package work.</p>
<p>Here is the screenshot of example SSIS package for Amazon MWS.</p>
<div id="attachment_7144" style="width: 641px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-pagination-example-listorders-nexttoken.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7144" class="size-full wp-image-7144" src="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-pagination-example-listorders-nexttoken.png" alt="Amazon MWS APi Pagination (ListOrders , ListOrdersByNextToken Example)" width="631" height="761" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-pagination-example-listorders-nexttoken.png 631w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-api-pagination-example-listorders-nexttoken-249x300.png 249w" sizes="(max-width: 631px) 100vw, 631px" /></a><p id="caption-attachment-7144" class="wp-caption-text">Amazon MWS APi Pagination (ListOrders , ListOrdersByNextToken Example)</p></div>
<p>&nbsp;</p>
<h3>Copy/Paste Properties</h3>
<p>Here is copy/paste values for properties listed above.</p><pre class="crayon-plain-tag">DirectPath:  https://mws.amazonservices.com/Orders/2013-09-01
EnablePageTokenForBody: True
Filter:  $.ListOrders[$tag$]Response.ListOrders[$tag$]Result.Orders.Order[*]
HasDifferentNextPageInfo: True
HttpRequestData:  Action=ListOrders[$tag$]&amp;SellerId=A1xxxxxxxx&amp;CreatedAfter=2018-09-01T04%3A00%3A00Z&amp;MarketplaceId.Id.1=ATVPDKIKX0DER
HttpRequestMethod:  POST
NextUrlAttribute: $.ListOrders[$tag$]Response.ListOrders[$tag$]Result.NextToken
NextUrlSuffix: &amp;NextToken=&lt;%nextlink_encoded%&gt;
NetUrlWait: 10000 (ms) -- slow down to avoid throttling ... Max 6 requests per minute, increase if you get API Limit Error
PagePlaceholders:  body=|ByNextToken;filter=|ByNextToken</pre><p>
&nbsp;</p>
<h3>Understanding Pagination Properties</h3>
<p>Here are various properties you have to set for Pagination.</p>
<div class="su-table su-table-alternate">
<table style="border-collapse: collapse;width: 100%;height: 154px" border="1">
<tbody>
<tr style="height: 22px">
<td style="width: 14.5161%;height: 22px">Property</td>
<td style="width: 85.4839%;height: 22px">Description</td>
</tr>
<tr style="height: 66px">
<td style="width: 14.5161%;height: 66px">Src</td>
<td style="width: 85.4839%;height: 66px">Change this to correct URL. Look at Scratchpad Response Details Tab and Findout first line after POST and before &#8220;?&#8221; . e.g. /Orders/2013-09-01  this will be used in your URL.<br />
<strong>Example: </strong><br />
https://mws.amazonservices.com/Orders/2013-09-01</td>
</tr>
<tr style="height: 22px">
<td style="width: 14.5161%;height: 22px">Body (i.e. RequestData)</td>
<td style="width: 85.4839%;height: 22px">Scratchpad shows HTTP POST section. You can copy that and remove  System supplied parameters and then arrange all in one line to form your Body for request.</p>
<p><strong>Example:</strong></p><pre class="crayon-plain-tag">POST /Orders/2013-09-01?AWSAccessKeyId=AKxxxxxxxxxx
  &amp;Action=ListOrders
  &amp;SellerId=A10zzzzzzz
  &amp;SignatureVersion=2
  &amp;Timestamp=2018-09-17T21%3A35%3A57Z
  &amp;Version=2013-09-01
  &amp;Signature=3GigipfRsQgzzzzzzzzzzzzzs%3D
  &amp;SignatureMethod=HmacSHA256</pre><p>
Above HTTP POST can be used as below for your Body in ZappySys Driver. Rest of the parameters are automatically supplied by system. See special placeholder named [$tag$] this gets replaced at runtime when you set <strong>EnablePageTokenForBody=True</strong> and <strong>HasDifferentNextPageInfo=True</strong></p><pre class="crayon-plain-tag">Action=ListOrders[$tag$]&amp;SellerId=A10zzzzzzz&amp;CreatedAfter=2018-09-01T04%3A00%3A00Z</pre><p>
</td>
</tr>
<tr style="height: 22px">
<td style="width: 14.5161%;height: 22px">Filter</td>
<td style="width: 85.4839%;height: 22px">Change this parameter according to XML structure in the response.<br />
For example: If you see below response (first xml) in Scratchpad then your Filter will be<br />
<strong>$.ListOrdersResponse.ListOrdersResult.Orders.Order[*]</strong><br />
to enable pagination refer to <a href="https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_ListOrdersByNextToken.html" target="_blank" rel="noopener">Sample listed here</a> (click Example response at the bottom of that page). In second response and onwards your Filter should be below (See Bold Part).<br />
$ListOrders<strong>ByNextToken</strong>Response.ListOrders<strong>ByNextToken</strong>Result.Orders.Order[*]However in Driver we <strong>replace ByNextToken</strong> with <strong>[$tag$]</strong>. Like below. Using [$tag$] will automatically pick up the correct filter based on page number. You must set HasDifferentNextPageInfo=True to use [$tag$] feature.<strong>$.ListOrders[$tag$]Response.ListOrders[$tag$]Result.Orders.Order[*]</strong>Example of <strong>first page response</strong></p><pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;ListOrdersResponse xmlns="https://mws.amazonservices.com/
    Orders/2013-09-01"&gt;
    &lt;ListOrdersResult&gt;
        &lt;NextToken&gt;2YgYW55IxxxxxxxxxxxxVyZS4=&lt;/NextToken&gt;
        &lt;LastUpdatedBefore&gt;2017-02-25T18%3A10%3A21.687Z&lt;/LastUpdatedBefore&gt;
        &lt;Orders&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
        &lt;/Orders&gt;
    &lt;/ListOrdersResult&gt;
&lt;/ListOrdersResponse&gt;</pre><p>
Example of <strong>next page response</strong></p><pre class="crayon-plain-tag">&lt;?xml version="1.0"?&gt;
&lt;ListOrdersByNextTokenResponse xmlns="https://mws.amazonservices.com/
    Orders/2013-09-01"&gt;
    &lt;ListOrdersByNextTokenResult&gt;
        &lt;NextToken&gt;2YgYW55IxxxxxxxxxxxxVyZS4=&lt;/NextToken&gt;
        &lt;LastUpdatedBefore&gt;2017-02-25T18%3A10%3A21.687Z&lt;/LastUpdatedBefore&gt;
        &lt;Orders&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
            &lt;Order&gt; ....... &lt;/Order&gt;
        &lt;/Orders&gt;
    &lt;/ListOrdersResult&gt;
&lt;/ListOrdersResponse&gt;</pre><p>
</td>
</tr>
<tr style="height: 22px">
<td style="width: 14.5161%;height: 22px">NextUrlAttribute</td>
<td style="width: 85.4839%;height: 22px">This property defines which attributes indicate Token for next page. You can use this token in Body of next request (see NextUrlSuffix and EnablePageTokenForBody). You must set <strong>EnablePageTokenForBody=true</strong> to use Extracted token in Body.</td>
</tr>
<tr>
<td style="width: 14.5161%">StopIndicatorAttribute</td>
<td style="width: 85.4839%">Some APIs like  <a href="https://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportRequestList.html">GetReportRequestList</a> stop pagination based on <strong>HasNext</strong> attribute value. (ListOrders doesnt need this property to be set). Use this property to extract HasNext from response by supplying correct Filter expression. You also need to set NextUrlEndIndicator property which defines static value which indicates the last page. Example properties as below.</p><pre class="crayon-plain-tag">NextUrlEndIndicator=false
StopIndicatorAttributeOrExpr= $.GetReportRequestList[$tag$]Response.GetReportRequestList[$tag$]Result.HasNext</pre><p>
</td>
</tr>
<tr>
<td style="width: 14.5161%">NextUrlSuffix</td>
<td style="width: 85.4839%">This is used to create a string for NextToken attribute for next page request. If you want to just append extracted token to Body then you dont have to set this but in our case, we have to use &amp;NextToken=EncodedValueOfExtractedToken so we have used <strong>&amp;NextToken=&lt;%nextlink_encoded%&gt;</strong> expression.</td>
</tr>
<tr>
<td style="width: 14.5161%">PagePlaceholders</td>
<td style="width: 85.4839%">This property contains [$tag$] values for first page and next pages. You can define tags for filter, body or header. Each pair must be pipe delimited. First value or pair is [$tag$]  for first request and second value of the pair is [$tag$] for any next request afterwards. Our first request use blank value for [$tag$].<br />
Example:  <strong>PagePlaceholders=&#8217;body=|ByNextToken;filter=|ByNextToken&#8217;</strong></td>
</tr>
<tr>
<td style="width: 14.5161%">HasDifferentNextPageInfo</td>
<td style="width: 85.4839%">Set to True &#8211; This enables use of [$tag$] inside body, filter, headers to use different values of first request and second onwards requests.</td>
</tr>
<tr>
<td style="width: 14.5161%">EnablePageTokenForBody</td>
<td style="width: 85.4839%">Set to True &#8211; This appends value extracted from <strong>NextUrlSuffix</strong> inside body (e.g. NextToken).</td>
</tr>
</tbody>
</table>
</div>
<h2>Amazon MWS API Pagination (For Old Version)</h2>
<p>So in previous section we saw how to achieve pagination in one step (for newer version of SSIS PowerPack). But there will be a case you cannot use latest SSIS PowerPack or you want to take complete control on each aspect of pagination. In such case use below method (Depreciated).  In newer version we added many new properties so you dont have to do Loop pattern like below.</p>
<h3>Sample SSIS Package</h3>
<p>If you want to see complete working package for pagination pattern then <a href="//zappysys.com/blog/wp-content/uploads/2016/11/SSIS_Amazon_MWS_API_With_Loop_Example.zip" target="_blank" rel="noopener">download from here</a>. Change AccessKey, SecretKey, SellerID and Path as needed to make this package work.</p>
<p>Here is the screenshot of example SSIS package for Amazon MWS.</p>
<div id="attachment_893" style="width: 730px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/read-amazon-mws-web-api-paginate-nexttoken-load-to-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-893" class="wp-image-893 size-large" src="//zappysys.com/blog/wp-content/uploads/2016/10/read-amazon-mws-web-api-paginate-nexttoken-load-to-sql-server-1024x671.png" alt="SSIS Example Package - Read data from Amazon MWS Web service (API Call). Paginate API calls using NextToken" width="720" height="472" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/read-amazon-mws-web-api-paginate-nexttoken-load-to-sql-server-1024x671.png 1024w, https://zappysys.com/blog/wp-content/uploads/2016/10/read-amazon-mws-web-api-paginate-nexttoken-load-to-sql-server-300x196.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/10/read-amazon-mws-web-api-paginate-nexttoken-load-to-sql-server.png 1040w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-893" class="wp-caption-text">SSIS Example Package &#8211; Read data from Amazon MWS Web service (API Call). Paginate API calls using NextToken</p></div>
<h2>Load Amazon MWS API data into SQL Server using SSIS</h2>
<p>In this section we will see how to use <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZappySys XML Source connector</a> to read data from Amazon MWS Web Service and load into SQL Server</p>
<p>For making things simple we are calling</p>
<ol>
<li>Download and Install SSIS PowerPack</li>
<li>Create test package</li>
<li>From SSIS toolbox drag Data Flow task and double click task to go to Data Flow designer</li>
<li>Drag <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">ZS XML Source</a> from SSIS Toolbox</li>
<li>Configure XML Source as below
<div id="attachment_827" style="width: 704px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-xml-source-read-from-amazon-mws-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-827" class="size-full wp-image-827" src="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-xml-source-read-from-amazon-mws-api.png" alt="SSIS XML Source - Read data from Amazon MWS API (Amazon Marketplace Web service call)" width="694" height="683" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-xml-source-read-from-amazon-mws-api.png 694w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-xml-source-read-from-amazon-mws-api-300x295.png 300w" sizes="(max-width: 694px) 100vw, 694px" /></a><p id="caption-attachment-827" class="wp-caption-text">SSIS XML Source &#8211; Read data from Amazon MWS API (Amazon Marketplace Web service call)</p></div></li>
<li>Drag OLEDB destination from SSIS Toolbox.</li>
<li>Connect XML Source to OLEDB Destination and map input column to target table</li>
<li>Execute dataflow
<div id="attachment_828" style="width: 791px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-get-data-from-amazon-mws-web-service-call.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-828" class="size-full wp-image-828" src="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-get-data-from-amazon-mws-web-service-call.png" alt="Get data from Amazon MWS API - Save to File or SQL Server using SSIS" width="781" height="314" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-get-data-from-amazon-mws-web-service-call.png 781w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-get-data-from-amazon-mws-web-service-call-300x121.png 300w" sizes="(max-width: 781px) 100vw, 781px" /></a><p id="caption-attachment-828" class="wp-caption-text">Get data from Amazon MWS API &#8211; Save to File or SQL Server using SSIS</p></div></li>
</ol>
<h2>Working with Amazon MWS Feed API (e.g. Upload file)</h2>
<p>Amazon MWS Provides Feed APIs which has slight different requirements. Important requirement in Feed file upload is you have to supply Content MD5 Hash. If you use SSIS PowerPack then you don&#8217;t have to worry about that complexity because calculating MD5 Hash is automatically done.</p>
<h3>Upload Amazon MWS Feed File in TSV / CSV format (Tab separated)</h3>
<p>Here is the screenshot for how to upload Tab separated values in CSV file. You can specify body from Variable or Read from file. If you read from file then must check File Upload/Multi-Part option and start path with @ symbol as below.</p>
<div id="attachment_975" style="width: 965px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-feed-api-submitfeed-upload-file-csv-tab-format.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-975" class="size-full wp-image-975" src="//zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-feed-api-submitfeed-upload-file-csv-tab-format.png" alt="Call Amazon MWS Feed API - Upload CSV file format (Tab separated values - TSV) - XML" width="955" height="623" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-feed-api-submitfeed-upload-file-csv-tab-format.png 955w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-call-amazon-mws-feed-api-submitfeed-upload-file-csv-tab-format-300x196.png 300w" sizes="(max-width: 955px) 100vw, 955px" /></a><p id="caption-attachment-975" class="wp-caption-text">Call Amazon MWS Feed API &#8211; Upload CSV file format (Tab separated values &#8211; TSV)</p></div>
<h3>Upload Amazon MWS Feed File in XML format</h3>
<p>To upload feed file in XML format use same settings as above except Content Type should be XML (text/xml) (Select in the dropdown)</p>
<h2>Calling Amazon Product Advertising API</h2>
<p>If you have need to call <a href="http://docs.aws.amazon.com/AWSECommerceService/latest/GSG/Welcome.html" target="_blank" rel="noopener">Amazon Product Advertising API</a> then also you can use above techniques (Use MWS Provider on OAuth connection) to call Product Advertise API. Both API (MWS API and Product Advertise API) use same signature hashing algorithm so its possible to use MWS Provider for Hashing. You may have to change your API URL parameters as needed when you call Amazon Product Advertising API. Basically when you call any MWS or Product Advertising API using GET method then OAuth connection manager automatically appends Signature to URL at runtime.</p>
<h2>Import data from MWS Custom Reports (Inventory Report Example)</h2>
<p>Now lets look at how to extract data from <a href="https://docs.developer.amazonservices.com/en_UK/reports/Reports_ReportType.html" target="_blank" rel="noopener">Custom Report API</a> . Reading data from Custom Reports not single step process because report generation is Job style API. Which means you send report request and wait  until its done. Once Report ready you have to read in CSV format or XML. Some Reports only available in CSV format. <a href="https://docs.developer.amazonservices.com/en_UK/reports/Reports_Overview.html" target="_blank" rel="noopener">Check this post</a> to understand how complex it can be to get data. We will make it simple for you to understand this in 3 steps. Basically calling reports requires minimum 3 API calls (see below)</p>
<ol>
<li>Create a new report request &#8211; Cal <a href="https://docs.developer.amazonservices.com/en_UK/reports/Reports_RequestReport.html" target="_blank" rel="noopener">RequestReport</a> API . It returns <strong>ReportRequestId</strong> (You can use it in the next step)</li>
<li>Check Report Status see its done &#8211; Call <a href="https://docs.developer.amazonservices.com/en_UK/reports/Reports_GetReportRequestList.html" target="_blank" rel="noopener">GetReportRequestList</a> API (Pass <strong>ReportRequestId</strong> got in the previous step to get data for only one Report request we care). Keep checking Report Status every few seconds until you get <strong>_DONE_</strong> status in response.</li>
<li>Read Report Data &#8211; Call <a href="https://docs.developer.amazonservices.com/en_UK/reports/Reports_GetReport.html" target="_blank" rel="noopener">GetReport</a>. This API call returns CSV or XML data. So use correct component for this step. If CSV data is returned then we must use <a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-file-source-flat-file-web-api/" target="_blank" rel="noopener">CSV Source</a> rather than <a href="https://zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">XML Driver</a>.</li>
</ol>
<p>Now lets see how to read Amazon MWS custom report in SSIS. In this example, We will get Inventory by calling <strong>_GET_MERCHANT_LISTINGS_DATA_</strong> report type.</p>
<h3>Download Sample Package for MWS Report</h3>
<p>To make things simple we have created a demo package &#8211; ready to go.<br />
<a href="https://zappysys.com/blog/wp-content/uploads/2016/10/Amazon_MWS_API_GetReport_2012.zip">Download SSIS 2012 Demo &#8211; Amazon_MWS_API_GetReport_2012</a>.</p>
<h3>Prepare demo package for first run</h3>
<p>Once you download and extract above sample package. Import to your existing SSIS Solution. Its SSIS 2012 format so it may upgrade to higher version if you using SSIS 2014, 2016 or 2017.</p>
<p>Once package is opened perform following steps in before you can execute the package.</p>
<ol>
<li>Enter MarketplaceId, SellerId in Variables. Double click OAuth Connection and enter your MWS Account Key and Secret.</li>
<li>Create c:\temp directory (This is where we will save final report file)</li>
<li>Run this package</li>
<li>Go to Execution log and Find ReportId (This you can hardcode in Variables for Design time Preview / Metadata changes etc)</li>
</ol>
<p>See below package screenshot</p>
<div id="attachment_7128" style="width: 794px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-report-csv-xml-format.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7128" class="size-full wp-image-7128" src="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-report-csv-xml-format.png" alt="Read data from Amazon MWS Report in SSIS (Get Inventory Listing Example)" width="784" height="752" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-report-csv-xml-format.png 784w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-report-csv-xml-format-300x288.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-report-csv-xml-format-768x737.png 768w" sizes="(max-width: 784px) 100vw, 784px" /></a><p id="caption-attachment-7128" class="wp-caption-text">Read data from Amazon MWS Report in SSIS (Get Inventory Listing Example)</p></div>
<h3>Steps Explained</h3>
<p>Now lets see each steps in depth. We broken whole process in 3 groups.</p>
<h4>Create Report Request (Step1)</h4>
<p>This is the first step how you initiate report request.  Use <a href="https://zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/">REST API Task</a> to call this step. Here is raw request. Many items in body added at runtime (e.g. Signature, Timestamp).</p>
<ul>
<li>On Request tab see how we used SSIS Variables to get many values at runtime dynamically.</li>
<li>On Response Tab we have to extract RequestId and save into variable.</li>
</ul>
<pre class="crayon-plain-tag">POST 
https://mws.amazonservices.com/Reports/2009-01-01

AWSAccessKeyId=Axxxxxxxxx&amp;Action=RequestReport&amp;MarketplaceId=ATVPDKIKX0DER&amp;ReportType=_GET_MERCHANT_LISTINGS_DATA_&amp;SellerId=Axxxxxxxxx&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2019-06-05T21%3A23%3A31.090Z&amp;Signature=2AbGQQ4xxxxxxxxxxxxxxxxxxxxjJzox%2FU%3D</pre>
<div id="attachment_7129" style="width: 869px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-call-report-request.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7129" class="size-full wp-image-7129" src="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-call-report-request.png" alt="RequestReport Action - Generate Amazon MWS Custom Report" width="859" height="628" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-call-report-request.png 859w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-call-report-request-300x219.png 300w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-amazon-mws-call-report-request-768x561.png 768w" sizes="(max-width: 859px) 100vw, 859px" /></a><p id="caption-attachment-7129" class="wp-caption-text">RequestReport Action &#8211; Generate Amazon MWS Custom Report</p></div>
<div id="attachment_7130" style="width: 681px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-response-extract-xml-value-xpath-expression.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7130" class="size-full wp-image-7130" src="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-response-extract-xml-value-xpath-expression.png" alt="Extract value from XML response using XPATH and save to Variable (Get RequestId Example)" width="671" height="389" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-response-extract-xml-value-xpath-expression.png 671w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-response-extract-xml-value-xpath-expression-300x174.png 300w" sizes="(max-width: 671px) 100vw, 671px" /></a><p id="caption-attachment-7130" class="wp-caption-text">Extract value from XML response using XPATH and save to Variable (Get RequestId Example)</p></div>
<p>Here is how to configure above task</p>
<ol>
<li></li>
</ol>
<h4>Wait until data is ready (Step2)</h4>
<p>Once we send RepotRequest and we have RequestId we can call step2 using REST API Task. In this Task we can use Status Check Feature. This is pretty handy feature because we dont have to implement Loop in SSIS. Basically we have to keep checking report until we get _DONE_ status in the response (ReportProcessingStatus node in XML)</p>
<p>Here is how to configure the task.</p>
<ol>
<li>Request Tab Configuration.<br />
<strong>URL:</strong> <pre class="crayon-plain-tag">https://mws.amazonservices.com/Reports/2009-01-01</pre>
<strong>Method:</strong> POST<br />
<strong>Body:</strong> <pre class="crayon-plain-tag">Action=GetReportRequestList&amp;ReportRequestIdList.Id.1={{User::ReportRequestId}}&amp;MarketplaceId={{User::MarketplaceId}}&amp;SellerId={{User::SellerId}}</pre></li>
<li>Response Setting Tab Configuration<br />
<strong>Response content type:</strong> Xml<br />
<strong>Filter Expression:</strong>  <pre class="crayon-plain-tag">//*[local-name() = 'ReportProcessingStatus']  </pre></li>
<li>Status Check Tab<br />
<strong>Check Enable Status</strong><br />
<strong>Success Value:</strong>  <pre class="crayon-plain-tag">_DONE_</pre>
Check Every <strong>5</strong> Seconds</li>
</ol>
<div id="attachment_7131" style="width: 678px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-task-status-check-wait-until-ready-loop.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7131" class="size-full wp-image-7131" src="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-task-status-check-wait-until-ready-loop.png" alt="REST API Task - Status Check Feature (Wait until data is ready loop)" width="668" height="610" srcset="https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-task-status-check-wait-until-ready-loop.png 668w, https://zappysys.com/blog/wp-content/uploads/2016/10/ssis-rest-api-task-status-check-wait-until-ready-loop-300x274.png 300w" sizes="(max-width: 668px) 100vw, 668px" /></a><p id="caption-attachment-7131" class="wp-caption-text">REST API Task &#8211; Status Check Feature (Wait until data is ready loop)</p></div>
<h4>GetReportId (Step3)</h4>
<p>Once above task finished we can call same request again but this time we have to configure slightly different way.</p>
<p>Here is how to configure the task.</p>
<ol>
<li>Request Tab Configuration.<br />
<strong>URL:</strong> <pre class="crayon-plain-tag">https://mws.amazonservices.com/Reports/2009-01-01</pre>
<strong>Method:</strong> POST<br />
<strong>Body:</strong> <pre class="crayon-plain-tag">Action=GetReportRequestList&amp;ReportRequestIdList.Id.1={{User::ReportRequestId}}&amp;MarketplaceId={{User::MarketplaceId}}&amp;SellerId={{User::SellerId}}</pre></li>
<li>Response Setting Tab Configuration<br />
<strong>Response content type:</strong> Xml<br />
<strong>Filter Expression:</strong>  <pre class="crayon-plain-tag">//*[local-name() = 'GeneratedReportId']  </pre>
<strong>Check Save to Variable: </strong>Save to <strong>User::ReportId</strong></li>
<li>Status Check Tab<br />
<strong>Make Enable Status is unchecked</strong></li>
</ol>
<h4>Get Report Data  (Step4,Step5 or Step6)</h4>
<p>Now we are ready to ready our report. There are two ways we can do in SSIS.</p>
<ul>
<li>First approach (step 4,5) is download the report and save to local disk and then in the next step we can use data flow (CSV Source) to parse the saved file.</li>
<li>Second approach (step6) is rather than saving to disk we can directly call API using CSV File source and parse content that way. Lets talk each approach briefly.</li>
</ul>
<h5>Step4,5 &#8211; Load Report From File</h5>
<p>If you wish to save Report on disk then you can use REST API Task and call request like below.</p>
<p>Here is how to configure the task to download the file.</p>
<ol>
<li>Request Tab Configuration.<br />
<strong>URL:</strong> <pre class="crayon-plain-tag">https://mws.amazonservices.com/Reports/2009-01-01</pre>
<strong>Method:</strong> POST<br />
<strong>Body:</strong> Action=GetReport&amp;ReportId={{User::ReportId}}&amp;MarketplaceId={{User::MarketplaceId}}&amp;SellerId={{User::SellerId}}</li>
<li>Response Setting Tab Configuration<br />
<strong>Response content type:</strong> Xml<br />
<strong>Filter Expression:</strong>  <pre class="crayon-plain-tag">//*[local-name() = 'GeneratedReportId']  </pre>
<strong>Check Save to Variable: </strong>Save to <strong>User::ReportId<br />
</strong></li>
<li>On Response Settings Tab : Set Response charset to <strong>Western European [Windows 1252]</strong>  (or directly set via Properties Grid to <strong>Windows-1252</strong> under ResponseCharset Property)<strong><br />
</strong></li>
<li>Status Check Tab<br />
<strong>Make Enable Status is unchecked</strong></li>
</ol>
<p>To read download CSV file use settings described in below section except URL change it with local file path.</p>
<h5>Step6 &#8211; Load report from URL</h5>
<p>If you wish to load directly from URL then use same setting as above but in CSV Source inside data flow.</p>
<p>Here is how to configure CSV Source.</p>
<ol>
<li>Request Tab Configuration.<br />
<strong>URL:</strong> <pre class="crayon-plain-tag">https://mws.amazonservices.com/Reports/2009-01-01</pre>
<strong>Method:</strong> POST<br />
<strong>Body:</strong> <pre class="crayon-plain-tag">Action=GetReport&amp;ReportId={{User::ReportId}}&amp;MarketplaceId={{User::MarketplaceId}}&amp;SellerId={{User::SellerId}} </pre></li>
<li>General Tab<br />
<strong>Column Delimiter:</strong> {TAB}</li>
<li>On Encoding Tab : Set to Western European [Windows 1252]  (or directly set via Properties Grid to <strong>Windows-1252</strong> under CharacterSet Property)</li>
</ol>
<h2>Conclusion</h2>
<p>Amazon Marketplace Web service (MWS) provides great way to automate many functionality for Marketplace Seller. Using ZappySys <a href="//zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> you con consume data from any REST API or Web service without replying on SDK / coding approach (e.g. C#, Java, Python, Ruby).</p>
<p>The post <a href="https://zappysys.com/blog/call-amazon-mws-api-using-ssis-marketplace-web-service/">How to call Amazon MWS API using SSIS</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>
		<item>
		<title>How to get data from Google AdWords using SSIS</title>
		<link>https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/</link>
					<comments>https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/#comments</comments>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 13 Jun 2016 16:32:55 +0000</pubDate>
				<category><![CDATA[Google API]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[AdWords]]></category>
		<category><![CDATA[API Integration]]></category>
		<category><![CDATA[DFP]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[google api]]></category>
		<category><![CDATA[Google DoubleClick]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[rest api]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml source]]></category>
		<guid isPermaLink="false">http://zappysys.com/blog/?p=564</guid>

					<description><![CDATA[<p>Introduction Google AdWords is one of the most popular Advertise Platforms. In this article, you will learn how to get data from Google AdWords by calling Google AdWords Web Service method and using drag and drop SSIS XML/SOAP connector (No coding required :)). Google AdWords Web Services allows retrieving various data such as account info, campaigns; [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/">How to get data from Google AdWords 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-ads-connector/">API Connector for Google AdWords</a> which makes it much simpler to <strong>Read/Write Google AdWords Data in SSIS/ODBC</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).<br />
</div></div>
<p style="text-align: justify;"><strong><a href="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-integration.png"><img loading="lazy" decoding="async" class=" wp-image-1663 alignleft" src="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-integration.png" alt="" width="128" height="128" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-integration.png 273w, https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-integration-150x150.png 150w" sizes="(max-width: 128px) 100vw, 128px" /></a>Google AdWords</strong> is one of the most popular Advertise Platforms. In this article, you will learn <em>how to get data from Google AdWords</em> by calling Google AdWords Web Service method and using drag and drop <strong><a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener">SSIS XML/SOAP connector</a></strong> (No coding required :)). Google AdWords Web Services allows retrieving various data such as account info, campaigns; as well as writing data, such as creating a campaign, add a keyword. Basically, it allows controlling your AdWords account programmatically instead of using the AdWords dashboard. For demo purposes, we will <strong>get data from Google AdWords</strong> Account and <strong>load it into Microsoft SQL Server </strong>(but you can use this technique to save any supported targets in SSIS (e.g. Excel, FlatFile, Oracle, MySQL, IBM DB2, etc.).</p>
<p>If you desire to download a report from AdWords, you must follow a different approach described in an <a href="https://zappysys.com/blog/download-adwords-report-using-google-api-odbc-xml-driver/">article on how to download AdWords report</a>. It describes how to download a report using ODBC and XML Driver but the concepts introduced there can be applied to SSIS as well.</p>
<p>If you are looking for a similar article for <strong>Google DoubleClick for Publisher</strong> (Google DFP) then <a href="//zappysys.com/blog/calling-google-dfp-api-with-ssis-doubleclick-soap-api/" target="_blank" rel="noopener">check this article</a>.</p>
<p>You will also learn <strong>how to create Google Ads</strong> or modify any other objects by calling SOAP API using <u><span style="color: #000080;">SSIS REST API Task</span></u>.</p>
<h2>SSIS Tasks/Connectors discussed in this Article</h2>
<p>In this article we will use following Connector(s) and Connection Manager to archive full data integration with Google AdWords.</p>
<p>Following SSIS Connectors support <strong>OAuth Connectivity</strong>. When you use below connectors no coding required to pull data from any OAuth enabled services (e.g. Twitter, Facebook, LinkedIn).</p>
<div class="su-table su-table-alternate">
<table>
<tbody>
<tr>
<td width="36"><span style="color: #248cc8"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-rest-api-web-service-task.png" alt="Custom SSIS Tasks - Call REST API Webservice (GET, POST, DELETE etc)" width="32" /></span></td>
<td><u><span style="color: #248cc8"><a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">REST API Task</a></span></u></td>
</tr>
<tr>
<td width="36"><span style="color: #248cc8"><img decoding="async" src="//zappysys.com/onlinehelp/ssis-powerpack/scr/images/oauth-connection/ssis-oauth-connection-manager.png" alt="SSIS OAuth Connection Manager" width="32" /></span></td>
<td><a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/ssis-oauth-connection-manager.htm" target="_blank" rel="noopener"><span style="color: #248cc8">OAuth Connection Manager</span></a></td>
</tr>
<tr>
<td width="36"><span style="color: #248cc8"><img decoding="async" src="//zappysys.com/images/ssis-powerpack/ssis-xml-source.png" alt="Custom SSIS Components - XML Source (File, REST, SOAP)" width="32" /></span></td>
<td><a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/" target="_blank" rel="noopener"><span style="color: #248cc8">XML Source (REST API, SOAP Call or File data)</span></a></td>
</tr>
</tbody>
</table>
</div>
<h2>Two different ways to get Google AdWords Data in SSIS</h2>
<p>There are two ways you can extract Google AdWords data in SSIS.</p>
<ol>
<li>Use <a href="//zappysys.com/products/ssis-powerpack/ssis-google-analytics-source-connector/" target="_blank" rel="noopener">Google Analytics Source</a> (For more info <a href="//zappysys.com/blog/get-data-from-google-analytics-in-ssis-using-rest-api-call/" target="_blank" rel="noopener">see this article</a>)  (Consume AdWords data using Google Analytics REST API)</li>
<li>Use XML Source along with OAuth connection manager (Consume AdWords data using SOAP API)</li>
</ol>
<p>In this article we will only discuss Approach #2. For approach #1 refer <a href="//zappysys.com/blog/get-data-from-google-analytics-in-ssis-using-rest-api-call/#How_to_read_google_Adwords_Data_using_Google_Analytics_Source" target="_blank" rel="noopener">see this link</a></p>
<p>Advantage of #2 is you get total control of full API set for AdWords but you have to do lot more manual work. For Approach #1 is lot simpler but you get access to limited reports (Dimensions and Metrics).</p>
<h2>Google AdWords API Integration Example Screenshot</h2>
<p>Below is screenshot of sample package discussed in this article (<a href="//zappysys.com/blog/wp-content/uploads/2016/06/OAuthGoogleAdWords_2012.zip" target="_blank" rel="noopener">Download from here</a>). As you can see we tried to demonstrate Reading data and Managing data (e.g. Create Ad) in the same package. You can extend these technique to perform any type of operations in <strong>Google AdWords</strong> or similar service such as <strong>DoubleClick for Publisher</strong></p>
<div id="attachment_573" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/ssis-package-extract-google-adwords-data-soap-api-create-ad-get-campaigns.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-573" class="wp-image-573" src="//zappysys.com/blog/wp-content/uploads/2016/06/ssis-package-extract-google-adwords-data-soap-api-create-ad-get-campaigns.png" alt="Google AdWords API Integration Example - Create Ad, Get Accounts, Get Campaigns, Get Ad Groups, Get Ads (Extract AdWords data via SOAP API) , Read data using Selector Method or use AWQL query language" width="600" height="391" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/ssis-package-extract-google-adwords-data-soap-api-create-ad-get-campaigns.png 732w, https://zappysys.com/blog/wp-content/uploads/2016/06/ssis-package-extract-google-adwords-data-soap-api-create-ad-get-campaigns-300x195.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-573" class="wp-caption-text">Google AdWords API Integration Example &#8211; Create Ad, Get Accounts, Get Campaigns, Get Ad Groups, Get Ads (Extract AdWords data via SOAP API, Read data using Selector Method or use AWQL query language)</p></div>
<h2>Step-By-Step Tutorial</h2>
<p>Here are few high level steps you will have to perform to extract data from <strong>Google AdWords API</strong> using SSIS. This section assumes you have ClientID and Developer Token to access data. if you don&#8217;t have that then read next 2-3 sections.</p>
<ol>
<li>Download and install <a href="//zappysys.com/products/ssis-powerpack/">SSIS PowerPack from here</a></li>
<li>Create new SSIS Project</li>
<li>From SSIS toolbox drag DataFlow Task and go to dataflow designer</li>
<li>From toolbox of drag <a href="//zappysys.com/products/ssis-powerpack/ssis-xml-source/">ZS XML Source</a></li>
<li>Double click <strong>XML Source</strong> to configure it</li>
<li>Specify API URL from which you want to read data<br />
Example : <span style="text-decoration: underline;">https://adwords.google.com/api/adwords/mcm/<strong>v201509</strong>/ManagedCustomerService</span></li>
<li>Now check Use Credentials check box and select New <strong>ZS-OAuth</strong> connection manager.</li>
<li>On connection manager UI you can select <strong>Google</strong> from Provider Dropdown.</li>
<li>Under Scopes enter following (Scope is basically permission)<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/auth/adwords</pre>
&nbsp;</li>
<li>Now click <strong>Generate Token</strong> and when prompted login and in the last step Accept.</li>
<li>If everything went ok then you will see <strong>AccessToken</strong> and <strong>RefreshToken</strong> populated.</li>
<li>Click <strong>Test connection</strong> and close the UI by clicking OK</li>
<li>Now on XML Source &#8211; Select HTTP Request Method as <strong>POST</strong></li>
<li>In the Request Body click edit and enter request as below (Replace DEV_TOKEN and CLIENT_ID placeholders below)<br />
<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://adwords.google.com/api/adwords/mcm/v201605"&gt;
			&lt;developerToken&gt;ENTER_YOUR_DEV_TOKEN_HERE&lt;/developerToken&gt;
			&lt;clientCustomerId&gt;ENTER_YOUR_CLIENT_ID_HERE&lt;/clientCustomerId&gt;
			&lt;userAgent&gt;ZappySys SSIS PowerPack v1&lt;/userAgent&gt;
		&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;get xmlns="https://adwords.google.com/api/adwords/mcm/{{User::ApiVersion}}"&gt;
			&lt;serviceSelector&gt;
				&lt;fields&gt;CustomerId&lt;/fields&gt;
				&lt;fields&gt;Name&lt;/fields&gt;
			&lt;/serviceSelector&gt;
		&lt;/get&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
&nbsp;</p>
<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 for Request Body then <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>. Google AdWords has many API endpoints for different service. 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 are calling ManagedCustomerService API for version <strong>v201609</strong> then your <strong>help page URL would be like this</strong><br />
<a href="https://developers.google.com/adwords/api/docs/reference/v201609/ManagedCustomerService" target="_blank" rel="noopener">https://developers.google.com/adwords/api/docs/reference/v201609/ManagedCustomerService</a></p>
<p>And on the same page you will see <strong>WSDL link below</strong><br />
<a href="https://ads.google.com/apis/ads/publisher/v201702/NetworkService?wsdl" target="_blank" rel="noopener">https://ads.google.com/apis/ads/publisher/v201702/NetworkService?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>
<p><a href="//zappysys.com/blog/calling-google-dfp-api-with-ssis-doubleclick-soap-api/#How_to_generate_SOAP_Request_Body_using_SoapUI_tool" target="_blank" rel="noopener">See this link for more information</a> (Its for Google DoubleClick Ad Platform but you will get an idea)</p>
</div></div></li>
<li>Go to Array handling tab at the bottom and enter text : <strong>ns2:entries</strong> &#8211; By doing this we will treat <strong>&lt;ns2:entries&gt;</strong> node as array eventhough only one entry found in response (By default content with multiple records treated as array).
<div id="attachment_571" style="width: 430px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/soap-xml-response-array-handling-adwords-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-571" class="size-full wp-image-571" src="//zappysys.com/blog/wp-content/uploads/2016/06/soap-xml-response-array-handling-adwords-api.png" alt="Handling Array Element Nodes in SOAP Response" width="420" height="134" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/soap-xml-response-array-handling-adwords-api.png 420w, https://zappysys.com/blog/wp-content/uploads/2016/06/soap-xml-response-array-handling-adwords-api-300x96.png 300w" sizes="(max-width: 420px) 100vw, 420px" /></a><p id="caption-attachment-571" class="wp-caption-text">Handling Array Element Nodes in SOAP Response</p></div></li>
<li>On the filter expression click edit and highlight entries node and click ok. This will produce something like below in filter textbox<br />
<pre class="crayon-plain-tag">$.soap:Envelope.soap:Body.ns2:getResponse.ns2:rval.ns2:entries[*]</pre>
&nbsp;</li>
<li>Now click preview to see actual data.</li>
<li>Click OK to save UI. Now you can connect source to target such as SQL Server or <a href="//zappysys.com/onlinehelp/ssis-powerpack/scr/trash-destination.htm" target="_blank" rel="noopener">Trash Destination</a>.</li>
</ol>
<blockquote><p>NOTE: in above example we used v201605 API version but change it to latest if this API is no more valid. Google expires API version pretty often so keep that in mind if you get depreciated API version error.</p></blockquote>
<h2>Register for Developer Token to access AdWords account data using API</h2>
<p>First important step to access any Google AdWords Account is request developer token. <a href="https://developers.google.com/adwords/api/docs/guides/first-api-call" target="_blank" rel="noopener">Click this link</a> for step by step information. Watch short vide to get overview on entire process to access data via API.</p>
<h2>Find your Client ID</h2>
<p>Next thing you will need to know is your ClientID. Most of API Requests will require your ClientID. Perform following steps to find your ClientID.</p>
<p>Login to your AdWords Account using email address. At the top you will see your client ID as below screenshot.</p>
<div id="attachment_567" style="width: 610px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-account-client-id-for-soap-api-calls.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-567" class="wp-image-567" src="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-account-client-id-for-soap-api-calls.png" alt="How to find ClientID of your Google AdWords Account (Useful for making SOAP API Calls)" width="600" height="174" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-account-client-id-for-soap-api-calls.png 920w, https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-account-client-id-for-soap-api-calls-300x87.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></a><p id="caption-attachment-567" class="wp-caption-text">How to find ClientID of your Google AdWords Account (Useful for making SOAP API Calls)</p></div>
<p>&nbsp;</p>
<h2>Connect to Google AdWords API using OAuth</h2>
<p>Connecting to any Google API will require OAuth 2.0. SSIS PowerPack has Protocol so you can easily extract data from API without coding complex token extract/renew workflow. Such things usually requires some sort of programming but in our case you will do few clicks as described in Step-By-Step section earlier.</p>
<p>Here is the screenshot of OAuth Connection Manager.</p>
<div id="attachment_575" style="width: 660px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/calling-google-adwords-api-using-oauth-in-ssis.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-575" class="wp-image-575" src="//zappysys.com/blog/wp-content/uploads/2016/06/calling-google-adwords-api-using-oauth-in-ssis.png" alt="Connecting to Google AdWords API using OAuth 2.0 in SSIS (Consuming XML/SOAP API)" width="650" height="403" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/calling-google-adwords-api-using-oauth-in-ssis.png 932w, https://zappysys.com/blog/wp-content/uploads/2016/06/calling-google-adwords-api-using-oauth-in-ssis-300x186.png 300w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-575" class="wp-caption-text">Connecting to Google AdWords API using OAuth 2.0 in SSIS (Consuming XML/SOAP API)</p></div>
<p>&nbsp;</p>
<h2>Extract data from Google AdWords using SOAP API Calls</h2>
<p>When you define filter expression you can check/uncheck &#8220;Include Parent Columns&#8221; setting. For AdWords SOAP Api you can uncheck so you only extract columns from rvals node in XML Response.</p>
<div id="attachment_576" style="width: 560px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-select-xml-path-soap-request.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-576" class="wp-image-576" src="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-select-xml-path-soap-request.png" alt="Extract data from Google AdWords SOAP/XML Response" width="550" height="444" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-select-xml-path-soap-request.png 686w, https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-api-select-xml-path-soap-request-300x242.png 300w" sizes="(max-width: 550px) 100vw, 550px" /></a><p id="caption-attachment-576" class="wp-caption-text">Extract data from Google AdWords SOAP/XML Response</p></div>
<p>&nbsp;</p>
<h2>SOAP Response Paging / Looping</h2>
<p>Many time you will get response which is larger than default page size in AdWords API Call. In that case you can specify few pagination attributes on XML Source Paging tab. For more information on paging options you may refer <a href="//zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">this article</a> . This article is talking about JSON Source but same options are applicable for XML Source too.</p>
<div id="attachment_626" style="width: 513px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/04/ssis-xml-soap-api-pagination-google-adwords-pass-page-number.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-626" class="size-full wp-image-626" src="//zappysys.com/blog/wp-content/uploads/2016/04/ssis-xml-soap-api-pagination-google-adwords-pass-page-number.png" alt="REST API Pagination - Passing PageNumber inside POST Body (Example: Google AdWords SOAP Api)" width="503" height="547" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-xml-soap-api-pagination-google-adwords-pass-page-number.png 503w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-xml-soap-api-pagination-google-adwords-pass-page-number-276x300.png 276w" sizes="(max-width: 503px) 100vw, 503px" /></a><p id="caption-attachment-626" class="wp-caption-text">REST API Pagination &#8211; Passing PageNumber inside POST Body (Example: Google AdWords SOAP Api)</p></div>
<p>&nbsp;</p>
<div id="attachment_625" style="width: 665px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-pagination-pass-page-number-inside-request-body-post-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-625" class="size-full wp-image-625" src="//zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-pagination-pass-page-number-inside-request-body-post-data.png" alt="Configure REST API Pagination - using Page Number via POST Body Method" width="655" height="447" srcset="https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-pagination-pass-page-number-inside-request-body-post-data.png 655w, https://zappysys.com/blog/wp-content/uploads/2016/04/ssis-rest-api-pagination-pass-page-number-inside-request-body-post-data-300x205.png 300w" sizes="(max-width: 655px) 100vw, 655px" /></a><p id="caption-attachment-625" class="wp-caption-text">Configure REST API Pagination &#8211; using Page Number via POST Body Method</p></div>
<h2>Read Google AdWords data and Load into SQL Server</h2>
<p>Using XML Source you can extract data in tabular format and then you can map that to SQL Server Target (Use OLEDB Destination / ADO.net Destination).</p>
<div id="attachment_579" style="width: 719px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/extract-data-from-google-adwords-load-into-sql-server-using-ssis.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-579" class="size-full wp-image-579" src="//zappysys.com/blog/wp-content/uploads/2016/06/extract-data-from-google-adwords-load-into-sql-server-using-ssis.png" alt="Extract data from Google AdWords and load into SQL Server table using SSIS" width="709" height="403" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/extract-data-from-google-adwords-load-into-sql-server-using-ssis.png 709w, https://zappysys.com/blog/wp-content/uploads/2016/06/extract-data-from-google-adwords-load-into-sql-server-using-ssis-300x171.png 300w" sizes="(max-width: 709px) 100vw, 709px" /></a><p id="caption-attachment-579" class="wp-caption-text">Extract data from Google AdWords and load into SQL Server table using SSIS</p></div>
<h2>Write data / Manage AdWords Account via REST API Calls</h2>
<p>So far we have seen how to read data from AdWords account. But what if you have to create new records or write/update AdWords data via API Calls in automated manner? No worry &#8211; If you have need for that then use <a href="//zappysys.com/products/ssis-powerpack/ssis-rest-api-web-service-task/" target="_blank" rel="noopener">SSIS REST API Task</a> which supports adhoc HTTP WebRequests including POST/DELETE/PUT etc. You can also upload files via REST API call using this task. This task supports rich error handling and saving your response into variable or files.</p>
<h3>Create Ad under specific AdGroup</h3>
<p>Below example shows how to create new ad under specific AdGroup using <u><span style="color: #000080;">REST API Task</span></u></p>
<p>Notice we have used few placeholders to make things dynamic using SSIS Variables. Once REST API Task is executed you will see new ad created.</p>
<div id="attachment_577" style="width: 590px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-create-new-ad-using-soap-xml-api-ssis.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-577" class="wp-image-577" src="//zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-create-new-ad-using-soap-xml-api-ssis.png" alt="Creating Google AdWords Ad using SOAP/XML API in SSIS (REST API Task)" width="580" height="464" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-create-new-ad-using-soap-xml-api-ssis.png 703w, https://zappysys.com/blog/wp-content/uploads/2016/06/google-adwords-create-new-ad-using-soap-xml-api-ssis-300x240.png 300w" sizes="(max-width: 580px) 100vw, 580px" /></a><p id="caption-attachment-577" class="wp-caption-text">Creating Google AdWords Ad using SOAP/XML API in SSIS (REST API Task)</p></div>
<div id="attachment_578" style="width: 660px" class="wp-caption alignnone"><a href="//zappysys.com/blog/wp-content/uploads/2016/06/create-new-google-adwords-ad-via-soap-api-in-ssis.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-578" class="wp-image-578" src="//zappysys.com/blog/wp-content/uploads/2016/06/create-new-google-adwords-ad-via-soap-api-in-ssis.png" alt="Verify Google Ad created programmatically using SOAP/XML API Call (SSIS REST API Task)" width="650" height="353" srcset="https://zappysys.com/blog/wp-content/uploads/2016/06/create-new-google-adwords-ad-via-soap-api-in-ssis.png 916w, https://zappysys.com/blog/wp-content/uploads/2016/06/create-new-google-adwords-ad-via-soap-api-in-ssis-300x163.png 300w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-578" class="wp-caption-text">Verify Google Ad created programmatically using SOAP/XML API Call (SSIS REST API Task)</p></div>
<h2>Methods for Creating new records</h2>
<p>Google AdWords API supports <strong>mutate</strong> method for writing data. Many service endpoints supports this method. Below example request will create new Ad.</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://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;developerToken&gt;{{User::varDevToken}}&lt;/developerToken&gt;
			&lt;clientCustomerId&gt;{{User::varClientId}}&lt;/clientCustomerId&gt;
			&lt;userAgent&gt;My Test AdWords App (AwApi-DotNet/18.20.0, Common-Dotnet/3.11.0, .NET CLR/4.0.30319.18444, gzip)&lt;/userAgent&gt;
		&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;mutate xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;operations&gt;
				&lt;operator&gt;ADD&lt;/operator&gt;
				&lt;operand&gt;
	                &lt;adGroupId&gt;30800928123&lt;/adGroupId&gt;
	                &lt;ad xsi:type="TextAd"&gt;
	                    &lt;displayUrl&gt;//zappysys.com/ad1&lt;/displayUrl&gt;
	                    &lt;finalUrls&gt;//zappysys.com/ad1&lt;/finalUrls&gt;
	                    &lt;headline&gt;This is my Ad&lt;/headline&gt;
	                    &lt;description1&gt;This is Line 1&lt;/description1&gt;
	                    &lt;description2&gt;This is Line 2&lt;/description2&gt;
	                &lt;/ad&gt;            
				&lt;/operand&gt;
			&lt;/operations&gt;
		&lt;/mutate&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<h2>Methods for Reading AdWords data</h2>
<p>Google AdWords API supports two methods for reading data. Most of AdWords service endpoints supports GET method also known as Selector method (Its basically sending query in XML format). Seconds method is Query Method. It uses SQL like query language known as <a href="https://developers.google.com/adwords/api/docs/guides/awql" target="_blank" rel="noopener">AWQL</a>. (Read more about <a href="https://developers.google.com/adwords/api/docs/guides/awql" target="_blank" rel="noopener">AWQL query language</a>). If you are SQL Programmer then you may like AWQL Query method better than Selector. But either way you will be able to pass following information.</p>
<ul>
<li>Columns you want to return</li>
<li>Filter (e.g. Where Clause)</li>
<li>Order By</li>
<li>Paging information (e.g. PageNumber, PageSize)</li>
</ul>
<h3>Get Method (XML Selector)</h3>
<p>For Get Method using XML tags to define columns, filters and order by/paging information. Here is example Get method for below select query</p><pre class="crayon-plain-tag">SELECT Id, Heading
WHERE Status = 'ENABLED'
ORDER BY Heading DESC 
LIMIT 0,50</pre><p>
<strong>Get Request (Get all Active Ads)</strong></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://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;{{User::varDevToken}}&lt;/developerToken&gt;
			&lt;clientCustomerId xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;{{User::varClientId}}&lt;/clientCustomerId&gt;
			&lt;userAgent xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;My Test AdWords App (AwApi-DotNet/18.20.0, Common-Dotnet/3.11.0, .NET CLR/4.0.30319.18444, gzip)&lt;/userAgent&gt;
		&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;get xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;serviceSelector&gt;
			    &lt;fields&gt;Id&lt;/fields&gt;
			    &lt;fields&gt;Headline&lt;/fields&gt;
			    &lt;predicates&gt;
			        &lt;field&gt;Status&lt;/field&gt;
			        &lt;operator&gt;EQUALS&lt;/operator&gt;
			        &lt;values&gt;ENABLED&lt;/values&gt;
			    &lt;/predicates&gt;
			    &lt;ordering&gt;
			        &lt;field&gt;Headline&lt;/field&gt;
			        &lt;sortOrder&gt;ASCENDING&lt;/sortOrder&gt;
			    &lt;/ordering&gt;
			    &lt;paging&gt;
			        &lt;startIndex&gt;0&lt;/startIndex&gt;
			        &lt;numberResults&gt;50&lt;/numberResults&gt;
			    &lt;/paging&gt;
			&lt;/serviceSelector&gt;
		&lt;/get&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
<h3>Query Method (AWQL Query &#8211; SQL like query language)</h3>
<p>Below is sample Soap request for AWQL Method to read Ads listed under from specific AdGroups. To learn more AWQL Query Syntax <a href="https://developers.google.com/adwords/api/docs/guides/awql" target="_blank" rel="noopener">Click Here</a>.</p>
<p>To learn more about which Columns you can use inside your AWQL Query <a href="https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201605-AdGroupAdService" target="_blank" rel="noopener">Click here.</a> Note that each service support different fields for Select Clause, Where Clause and Order By Clause. AWQL language can be also used to query Predefined AdWords Reports. The only difference is .. FROM clause is required when you query Reports.</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://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;YOUR_DEV_TOKEN&lt;/developerToken&gt;
			&lt;clientCustomerId xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;YOUR_CLIENT_ID&lt;/clientCustomerId&gt;
			&lt;userAgent xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;My Test AdWords App (AwApi-DotNet/18.20.0, Common-Dotnet/3.11.0, .NET CLR/4.0.30319.18444, gzip)&lt;/userAgent&gt;
		&lt;/RequestHeader&gt;
	&lt;/soap:Header&gt;
	&lt;soap:Body&gt;
		&lt;query xmlns="https://adwords.google.com/api/adwords/cm/v201605"&gt;
			&lt;query&gt;
SELECT Id, Name
WHERE Status = 'ENABLED'
LIMIT 0,5
			&lt;/query&gt;
		&lt;/query&gt;
	&lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre><p>
&nbsp;</p>
<h2>Call AdWords Reports API &#8211; Download Campaign Performance data</h2>
<p>There will be a time you like to <a href="https://developers.google.com/adwords/api/docs/guides/reporting#http_request_url" target="_blank" rel="noopener">download Reports from Adwords</a>. For that  <a href="https://zappysys.com/blog/download-adwords-report-using-google-api-odbc-xml-driver/" target="_blank" rel="noopener">read this article</a>. Its showing how to use ZappySys ODBC Driver to call AdWords Reporting API but concept is same in SSIS Product too due to similar UI elements.</p>
<h2>Download Example SSIS Package</h2>
<p><a href="//zappysys.com/blog/wp-content/uploads/2016/06/OAuthGoogleAdWords_2012.zip">Download SSIS 2012 / 2014/ 2016 Sample</a></p>
<h2>Conclusion</h2>
<p><em>Google AdWords data integration</em> can be very challenging without right set of tools. <a href="//zappysys.com/products/ssis-powerpack/">SSIS PowerPack</a> certainly makes it easy when you have to extract/manage Google AdWords data. Innovative drag and drop approach gives you various options to cover simple or most advanced scenarios without relying on any Programming language (e.g. C#, Java, Python, Ruby etc).</p>
<p>The post <a href="https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/">How to get data from Google AdWords using SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zappysys.com/blog/get-data-from-google-adwords-using-ssis/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
