<?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>gmail Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/gmail/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/gmail/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 05 Mar 2026 01:25:27 +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>gmail Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/gmail/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Download Gmail Attachment in SSIS</title>
		<link>https://zappysys.com/blog/download-gmail-attachment-in-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Wed, 30 Dec 2020 18:29:57 +0000</pubDate>
				<category><![CDATA[JSON File / REST API Driver]]></category>
		<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[varbinary]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=9207</guid>

					<description><![CDATA[<p>Introduction Downloading Gmail Attachments in SSIS is always a little more difficult than working with simple text or numeric columns. If you are not an SSIS expert, doing it for the first time may be challenging. That is why we created this article for you. This is a common request we receive, so we are [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/download-gmail-attachment-in-ssis/">Download Gmail Attachment in 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:#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>UPDATE:</strong> ZappySys has released a brand new <a href="https://zappysys.com/api/integration-hub/gmail-connector/ssis" target="_blank" rel="noopener">Gmail Connector for SSIS</a>, which makes it much simpler to <strong>download attachments, read / search Emails, users, mail folders, send emails, and more in SSIS</strong> compared to the steps listed in this article. You can still use the steps from this article, but if you are new to APIs or want to avoid the learning curve, use a newer approach.</div></div>
<p>Downloading Gmail Attachments in SSIS is always a little more difficult than working with simple text or numeric columns. If you are not an SSIS expert, doing it for the first time may be challenging. That is why we created this article for you. This is a common request we receive, so we are bringing this article to you.</p>
<p>Gmail is the most popular email service in the world, and it can be helpful to automate and get valuable information from it. We will connect to Gmail with the REST API. For that, if you are not an experienced user of the REST API, do not worry. This article is for you. We will provide simple steps for the connection.</p>
<h2>Requirements</h2>
<p>To do it, we will need the following components:</p>
<ol>
<li><a href="https://docs.microsoft.com/en-us/sql/ssdt/previous-releases-of-sql-server-data-tools-ssdt-and-ssdt-bi?view=sql-server-ver15">SSDT for SSIS</a> must be installed on your computer</li>
<li><a href="https://zappysys.com/products/ssis-powerpack/download/">ZappySys SSIS Powerpack</a> should be installed. This Powerpack Plugin includes connectors to Gmail via the REST API.</li>
</ol>
<p>&nbsp;</p>
<h2>Getting Started</h2>
<h3>Creating the connection</h3>
<ol>
<li>First of all, in SSDT, create a new SSIS project</li>
<li>To create a connection in SSDT, open the Connection Manager and select New Connection.
<div id="attachment_11671" style="width: 732px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Create-a-new-connection.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-11671" class="wp-image-11671 size-full" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Create-a-new-connection.png" alt="Create a new connection" width="722" height="229" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Create-a-new-connection.png 722w, https://zappysys.com/blog/wp-content/uploads/2020/12/Create-a-new-connection-300x95.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/Create-a-new-connection-720x229.png 720w" sizes="(max-width: 722px) 100vw, 722px" /></a><p id="caption-attachment-11671" class="wp-caption-text">Create a new connection</p></div></li>
<li>Select the ZS OAuth connection. This is a special connection included with the <a href="https://zappysys.com/products/ssis-powerpack/download/">ZS.<br />
SSIS PowerPack</a> installer that we will use to connect to Gmail.</p>
<div id="attachment_11676" style="width: 488px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Select-ZS-OAuth-connector.png"><img decoding="async" aria-describedby="caption-attachment-11676" class="wp-image-11676 size-full" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Select-ZS-OAuth-connector.png" alt="Select ZS-OAuth connector" width="478" height="447" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Select-ZS-OAuth-connector.png 478w, https://zappysys.com/blog/wp-content/uploads/2020/12/Select-ZS-OAuth-connector-300x281.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></a><p id="caption-attachment-11676" class="wp-caption-text">Select ZS-OAuth connector</p></div>
<div class="mceTemp"></div>
</li>
<li>In the ZS OAuth connection, select the Google API OAuth Provider and specify the following credentials and scope permissions:
<div id="attachment_11677" style="width: 713px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/SSIS-Gmail-connection-1.png"><img decoding="async" aria-describedby="caption-attachment-11677" class="size-full wp-image-11677" src="https://zappysys.com/blog/wp-content/uploads/2020/12/SSIS-Gmail-connection-1.png" alt="SSIS Gmail connection" width="703" height="674" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/SSIS-Gmail-connection-1.png 703w, https://zappysys.com/blog/wp-content/uploads/2020/12/SSIS-Gmail-connection-1-300x288.png 300w" sizes="(max-width: 703px) 100vw, 703px" /></a><p id="caption-attachment-11677" class="wp-caption-text">SSIS Gmail connection</p></div>
<pre class="crayon-plain-tag">https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.addons.current.message.readonly
https://www.googleapis.com/auth/gmail.addons.current.message.action</pre>
</li>
</ol>
<h3>Creating the package to download Gmail attachments in SSIS</h3>
<ol>
<li>First of all, drag and drop the Data Flow Task from the SSIS Toolbox and double-click it<br />
to edit.</p>
<div id="attachment_11622" style="width: 472px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/08/Drag-and-Drop-SSIS-Data-Flow-Task-from-SSIS-Toolbox.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11622" class="wp-image-11622 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/08/Drag-and-Drop-SSIS-Data-Flow-Task-from-SSIS-Toolbox.png" alt="" width="462" height="157" srcset="https://zappysys.com/blog/wp-content/uploads/2019/08/Drag-and-Drop-SSIS-Data-Flow-Task-from-SSIS-Toolbox.png 462w, https://zappysys.com/blog/wp-content/uploads/2019/08/Drag-and-Drop-SSIS-Data-Flow-Task-from-SSIS-Toolbox-300x102.png 300w" sizes="(max-width: 462px) 100vw, 462px" /></a><p id="caption-attachment-11622" class="wp-caption-text">Drag and Drop SSIS Data Flow Task from SSIS Toolbox</p></div></li>
<li>Secondly, in the Data Flow, we will use the JSON Source to connect to Gmail and get the attachments. JSON Source is a ZappySys component used now only to connect to JSON files, but also to connect to REST API Servers that support JSON. In this case, Gmail REST API can send information in JSON Format. Use the connection created before.</li>
<li>Basically, we need to specify the URL of the Gmail attachment. In Gmail, the email attachment is inside the message. Then you need to specify the <em>message-id</em> and the Gmail <em>attachment-id</em> like this:
<div id="attachment_11678" style="width: 838px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Zappysys-JSON-source-Gmail-attachments-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11678" class="size-full wp-image-11678" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Zappysys-JSON-source-Gmail-attachments-configuration.png" alt="Zappysys JSON source Gmail attachments configuration" width="828" height="717" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Zappysys-JSON-source-Gmail-attachments-configuration.png 828w, https://zappysys.com/blog/wp-content/uploads/2020/12/Zappysys-JSON-source-Gmail-attachments-configuration-300x260.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/Zappysys-JSON-source-Gmail-attachments-configuration-768x665.png 768w" sizes="(max-width: 828px) 100vw, 828px" /></a><p id="caption-attachment-11678" class="wp-caption-text">Zappysys JSON source Gmail attachments configuration</p></div>
<pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/messages/{{User::email_id}}/attachments/{{User::attachment_id}}</pre>
</li>
<li>Now, in the go-to columns tab, set the data type to DT_IMAGE and increase the length of the other columns&#8217; DT_WSTR fields by 1000 and 1500. We set <pre class="crayon-plain-tag">contentBytes</pre> to the <pre class="crayon-plain-tag">DT_IMAGE</pre>  datatype, it&#8217;s like <pre class="crayon-plain-tag">varbinary(MAX)</pre>
<div id="attachment_11675" style="width: 836px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/JSON-Source-Columns-Tab-attachment-datatype.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11675" class="size-full wp-image-11675" src="https://zappysys.com/blog/wp-content/uploads/2020/12/JSON-Source-Columns-Tab-attachment-datatype.png" alt="JSON Source Columns Tab - attachment datatype" width="826" height="331" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/JSON-Source-Columns-Tab-attachment-datatype.png 826w, https://zappysys.com/blog/wp-content/uploads/2020/12/JSON-Source-Columns-Tab-attachment-datatype-300x120.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/JSON-Source-Columns-Tab-attachment-datatype-768x308.png 768w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-11675" class="wp-caption-text">JSON Source Columns Tab &#8211; attachment datatype</p></div></li>
<li>Next, we will use the derived column to set the path to the local folder where the attachment will be stored. The derived column will be used to set the local path for the attachment. Make sure to specify valid paths with double backslashes, since backslashes are special characters. The derived column is a special transformation component that creates new columns. <a href="https://docs.microsoft.com/en-us/sql/integration-services/expressions/integration-services-ssis-expressions?view=sql-server-ver15">SSIS expressions</a>.
<div id="attachment_11672" style="width: 798px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Derived-columns-Gmail-attachment.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11672" class="size-full wp-image-11672" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Derived-columns-Gmail-attachment.png" alt="Derived columns - Gmail attachment" width="788" height="624" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Derived-columns-Gmail-attachment.png 788w, https://zappysys.com/blog/wp-content/uploads/2020/12/Derived-columns-Gmail-attachment-300x238.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/Derived-columns-Gmail-attachment-768x608.png 768w" sizes="(max-width: 788px) 100vw, 788px" /></a><p id="caption-attachment-11672" class="wp-caption-text">Derived columns &#8211; Gmail attachment file path</p></div></li>
<li>Also, we will require the Export column to download into a file. This component is specially used to get images or binary files into the file system.
<div id="attachment_11673" style="width: 763px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Export-columns-transformation-Gmail-attachment.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11673" class="size-full wp-image-11673" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Export-columns-transformation-Gmail-attachment.png" alt="Export columns transformation - Gmail attachment" width="753" height="637" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Export-columns-transformation-Gmail-attachment.png 753w, https://zappysys.com/blog/wp-content/uploads/2020/12/Export-columns-transformation-Gmail-attachment-300x254.png 300w" sizes="(max-width: 753px) 100vw, 753px" /></a><p id="caption-attachment-11673" class="wp-caption-text">Export columns transformation &#8211; Gmail attachment</p></div></li>
<li>Finally, we will use the <a href="https://zappysys.com/blog/ssis-trash-destination-dummy-data-source-example/">Trash destination</a> to get the attachment and finish the flow. This one is also a ZappySys component ubiquitous.</li>
<li>Your package should be something like this:
<div id="attachment_11674" style="width: 306px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/Final-Result-Gmail-attachment.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11674" class="size-full wp-image-11674" src="https://zappysys.com/blog/wp-content/uploads/2020/12/Final-Result-Gmail-attachment.png" alt="Final Result - Gmail attachment" width="296" height="320" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/Final-Result-Gmail-attachment.png 296w, https://zappysys.com/blog/wp-content/uploads/2020/12/Final-Result-Gmail-attachment-278x300.png 278w" sizes="(max-width: 296px) 100vw, 296px" /></a><p id="caption-attachment-11674" class="wp-caption-text">Final Result &#8211; Gmail attachment</p></div></li>
<li>The next step is to run it and test it.</li>
<li>If everything is fine, we will be able to see the file in your system.</li>
</ol>
<h2>Conclusion</h2>
<p>In conclusion, we learned how to download Gmail attachments in SSIS. Basically, you need to use the ZappySys JSON Source to connect to Gmail via the REST API, then use the derived column component to specify the path to store the attachment. The next step is to use the Export column component to export the attachment. Finally, the ZS Trash destination is the attachment&#8217;s destination. If you liked this article, do not hesitate to continue testing and using <a href="https://zappysys.com/">ZappySys PowerPack for SSIS.</a></p>
<h2>API Connector</h2>
<p>Here are a few examples with our <a href="https://zappysys.com/api/integration-hub/gmail-connector/ssis">API connector for Gmail </a></p>
<div id="attachment_11670" style="width: 992px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-get-message-attachments.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11670" class="size-full wp-image-11670" src="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-get-message-attachments.png" alt="API connector - Gmail get message attachments" width="982" height="684" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-get-message-attachments.png 982w, https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-get-message-attachments-300x209.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-get-message-attachments-768x535.png 768w" sizes="(max-width: 982px) 100vw, 982px" /></a><p id="caption-attachment-11670" class="wp-caption-text">API connector &#8211; Gmail get message attachments</p></div>
<div id="attachment_11669" style="width: 992px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-download-message-attachments.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-11669" class="size-full wp-image-11669" src="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-download-message-attachments.png" alt="API connector - Gmail download message attachments" width="982" height="684" srcset="https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-download-message-attachments.png 982w, https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-download-message-attachments-300x209.png 300w, https://zappysys.com/blog/wp-content/uploads/2020/12/API-connector-Gmail-download-message-attachments-768x535.png 768w" sizes="(max-width: 982px) 100vw, 982px" /></a><p id="caption-attachment-11669" class="wp-caption-text">API connector &#8211; Gmail download message attachments</p></div>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/download-gmail-attachment-in-ssis/">Download Gmail Attachment in SSIS</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to read REST API in Pentaho Kettle</title>
		<link>https://zappysys.com/blog/pentaho-read-rest-api-in-pentaho/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Sat, 04 Aug 2018 20:44:39 +0000</pubDate>
				<category><![CDATA[ETL - Pentaho Kettle]]></category>
		<category><![CDATA[JSON File / REST API Driver]]></category>
		<category><![CDATA[ODBC Gateway]]></category>
		<category><![CDATA[ODBC PowerPack]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[odbc]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[rest]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4545</guid>

					<description><![CDATA[<p>Introduction In this article, we will learn how to read REST API in Pentaho Kettle. Pentaho is a very popular tool in Business Intelligence to integrate data for OLAP services and to create reports and dashboards. In this article, we will use our ZappySys ODBC PowerPack to connect to REST API in Pentaho Kettle. Our software requires the JDBC connector [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/pentaho-read-rest-api-in-pentaho/">How to read REST API in Pentaho Kettle</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho.png"><img loading="lazy" decoding="async" class="alignleft wp-image-4640" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-150x150.png" alt="Pentaho logo" width="115" height="115" /></a>In this article, we will learn how to read REST API in Pentaho Kettle. Pentaho is a very popular tool in Business Intelligence to integrate data for OLAP services and to create reports and dashboards. In this article, we will use our <a href="https://zappysys.com/products/odbc-powerpack/purchase/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a> to connect to REST API in Pentaho Kettle.</p>
<p>Our software requires the JDBC connector for SQL Server and then Uses our ZappySys Gateway to connect.</p>
<h2></h2>
<h2>Requirements</h2>
<ol>
<li>First of all, we will require the <a href="https://zappysys.com/products/odbc-powerpack/purchase/" target="_blank" rel="noopener">ZappySys ODBC PowerPack.</a></li>
<li>Secondly, we will use <a href="https://community.hitachivantara.com/docs/DOC-1009855-data-integration-kettle" target="_blank" rel="noopener">Pentaho Kettle (Our example in this post uses v8.1)</a></li>
<li>Finally, we will require the <a href="https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-2017" target="_blank" rel="noopener">JDBC driver for SQL Server</a>.</li>
</ol>
<h2>Getting started</h2>
<p>First of all, we will need to create an ODBC connection to REST API using the Windows ODBC Data Source Administrator. Next, we will create a gateway and finally, we will invoke the data in Pentaho.</p>
<h3>Create an ODBC connection to read REST API in Pentaho Kettle</h3>
<p>In this example, we will first create an ODBC connection to an URL.</p>
<ol>
<li>First of all, open the ODBC Data Source administrator in Windows in the System DSN press Add:
<div id="attachment_4484" style="width: 600px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4484" class="size-full wp-image-4484" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png" alt="Include JSON driver in ODBC Data source" width="590" height="423" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png 590w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator-300x215.png 300w" sizes="(max-width: 590px) 100vw, 590px" /></a><p id="caption-attachment-4484" class="wp-caption-text">Add new ODBC driver</p></div></li>
<li>Secondly, select the ZappySys JSON Driver:
<div id="attachment_4485" style="width: 471px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4485" class="size-full wp-image-4485" src="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png" alt="Use ZappySys ODBC Driver" width="461" height="346" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png 461w, https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1-300x225.png 300w" sizes="(max-width: 461px) 100vw, 461px" /></a><p id="caption-attachment-4485" class="wp-caption-text">Select JSON driver in ODBC DS Administrator</p></div></li>
<li>Finally, add a data source name and specify a link to a URL. In this example, we will connect to the following url:<br />
<pre class="crayon-plain-tag">URL: https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json</pre>
<div id="attachment_4488" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4488" class="size-full wp-image-4488" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png" alt="URL for OData REST API" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4488" class="wp-caption-text">REST API ODBC URL</p></div></li>
</ol>
<h3>Create a ZappySys gateway to JDBC to read REST API in Pentaho</h3>
<p>In order to connect to REST API, ZappySys ODBC PowerPack uses the JDBC for SQL Server and a gateway. Let&#8217;s take a look at it:</p>
<ol>
<li>First of all, open the ZappySys Gateway that is installed with the ODBC PowerPack and add a new data source:
<div id="attachment_4490" style="width: 567px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4490" class="size-full wp-image-4490" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png" alt="Gateway add Data Source" width="557" height="209" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png 557w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway-300x113.png 300w" sizes="(max-width: 557px) 100vw, 557px" /></a><p id="caption-attachment-4490" class="wp-caption-text">Add new Data Source in ZappySys Gateway</p></div></li>
<li>Secondly, add the data source name:
<div id="attachment_4554" style="width: 378px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/new-datasource-odbc-odata-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4554" class="size-full wp-image-4554" src="https://zappysys.com/blog/wp-content/uploads/2018/08/new-datasource-odbc-odata-gateway.png" alt="Create gateway to REST API" width="368" height="158" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/new-datasource-odbc-odata-gateway.png 368w, https://zappysys.com/blog/wp-content/uploads/2018/08/new-datasource-odbc-odata-gateway-300x129.png 300w" sizes="(max-width: 368px) 100vw, 368px" /></a><p id="caption-attachment-4554" class="wp-caption-text">Pentaho REST Client</p></div></li>
<li>In addition, in the user&#8217;s tab, add the user test and specify a password:
<div id="attachment_2941" style="width: 377px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/03/zappysys-gateway-login.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-2941" class="size-full wp-image-2941" src="https://zappysys.com/blog/wp-content/uploads/2018/03/zappysys-gateway-login.png" alt="Add user and login" width="367" height="200" srcset="https://zappysys.com/blog/wp-content/uploads/2018/03/zappysys-gateway-login.png 367w, https://zappysys.com/blog/wp-content/uploads/2018/03/zappysys-gateway-login-300x163.png 300w" sizes="(max-width: 367px) 100vw, 367px" /></a><p id="caption-attachment-2941" class="wp-caption-text">Add user and login</p></div></li>
<li>Also, in settings, press edit and add the ODBC Data Source created in the previous section and add the user created before:
<div id="attachment_4491" style="width: 569px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-datasource-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4491" class="size-full wp-image-4491" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-datasource-gateway.png" alt="ODBC connection to Default gateway" width="559" height="477" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-datasource-gateway.png 559w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-datasource-gateway-300x256.png 300w" sizes="(max-width: 559px) 100vw, 559px" /></a><p id="caption-attachment-4491" class="wp-caption-text">Link Data Source in ODBC with the default gateway</p></div></li>
<li>Finally, in the General tab, you can specify the port. By default, it is 5000.<br />
Make sure to save the changes and check the gateway is started with the start button:</p>
<div id="attachment_4495" style="width: 572px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4495" class="size-full wp-image-4495" src="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png" alt="Port 5000 in the default gateway" width="562" height="539" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png 562w, https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port-300x288.png 300w" sizes="(max-width: 562px) 100vw, 562px" /></a><p id="caption-attachment-4495" class="wp-caption-text">Default gateway with port 5000</p></div></li>
</ol>
<h3>How to read REST API in Pentaho</h3>
<ol>
<li>First of all, in Pentaho, we will create a project like the following:
<div id="attachment_4556" style="width: 487px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-a-csv-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4556" class="size-full wp-image-4556" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-a-csv-file.png" alt="Client Pentaho REST API" width="477" height="162" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-a-csv-file.png 477w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-a-csv-file-300x102.png 300w" sizes="(max-width: 477px) 100vw, 477px" /></a><p id="caption-attachment-4556" class="wp-caption-text">Pentaho Project REST API csv</p></div></li>
<li>Secondly, we will create a query like the following:
<div id="attachment_4557" style="width: 555px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-table-input-query.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4557" class="size-full wp-image-4557" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-table-input-query.png" alt="SQL query to REST API in Pentaho" width="545" height="697" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-table-input-query.png 545w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-table-input-query-235x300.png 235w" sizes="(max-width: 545px) 100vw, 545px" /></a><p id="caption-attachment-4557" class="wp-caption-text">A query in Pentaho to get data</p></div></li>
<li>In addition, we will add the following connection. We will connect to the data source named customers created in the ZappySys Gateway with port 5000 and the user created in the Gateway:
<div id="attachment_4558" style="width: 1362px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4558" class="size-full wp-image-4558" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server.png" alt="How to connect to the Gateway" width="1352" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server.png 1352w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server-300x134.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server-768x343.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-JDBC-connection-sql-server-1024x457.png 1024w" sizes="(max-width: 1352px) 100vw, 1352px" /></a><p id="caption-attachment-4558" class="wp-caption-text">JDBC connection to SQL Server</p></div></li>
<li>If everything is OK, you will be able to see the CSV file generated:
<div id="attachment_4559" style="width: 1351px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4559" class="size-full wp-image-4559" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file.png" alt="Exported data from REST API to CSV" width="1341" height="506" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file.png 1341w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file-300x113.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file-768x290.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-to-csv-output-file-1024x386.png 1024w" sizes="(max-width: 1341px) 100vw, 1341px" /></a><p id="caption-attachment-4559" class="wp-caption-text">Data in CSV format</p></div></li>
<li>Also, you can use SQL statements. The following example shows how to do a where filter:<br />
<pre class="crayon-plain-tag">SELECT Shipname 
FROM value
where Shipname='Consolidated Holdings'</pre>
</li>
<li>Finally, we will show the first 10 rows using a group by:<br />
<pre class="crayon-plain-tag">SELECT Shipname 
FROM value
group by shipname
limit 10</pre>
</li>
</ol>
<h3>How to read REST API in Pentaho (Gmail)</h3>
<p>The following example will show how to get Gmail information from Pentaho.</p>
<ol>
<li>First of all, we will need to create a connection to Gmail in ODBC using the ZappySys ODBC Driver (Check the Create an ODBC connection for a Pentaho REST Client section). In the ODBC Administrator, we will add a ZappySys JSON Driver connection.</li>
<li>Secondly, in the ZappySys ODBC driver, specify the URL and select the OAuth connection:
<div id="attachment_4560" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/Pentaho-gmail-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4560" class="size-full wp-image-4560" src="https://zappysys.com/blog/wp-content/uploads/2018/08/Pentaho-gmail-configuration.png" alt="Configure ODBC to REST API" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/Pentaho-gmail-configuration.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/08/Pentaho-gmail-configuration-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/08/Pentaho-gmail-configuration-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4560" class="wp-caption-text">ODBC configuration</p></div></li>
<li>Also, in the OAuth properties specify the Google OAuth provider and the https://mail.google.com scope. Press the generate token button and specify your credentials and accept the access permission request:
<div id="attachment_4561" style="width: 596px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gmail-oauth-configuration.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4561" class="size-full wp-image-4561" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gmail-oauth-configuration.png" alt="Configure OAuth connection" width="586" height="493" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gmail-oauth-configuration.png 586w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gmail-oauth-configuration-300x252.png 300w" sizes="(max-width: 586px) 100vw, 586px" /></a><p id="caption-attachment-4561" class="wp-caption-text">Gmail OAuth connection</p></div></li>
<li>In addition, using the ZappysSys Data Gateway, add the new Data Source and associate with the ODBC connection just created:
<div id="attachment_4563" style="width: 572px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gateway-to-connect-to-gmail-ODBC.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4563" class="size-full wp-image-4563" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gateway-to-connect-to-gmail-ODBC.png" alt="Add ODBC to the ZappySys gateway" width="562" height="464" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gateway-to-connect-to-gmail-ODBC.png 562w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-gateway-to-connect-to-gmail-ODBC-300x248.png 300w" sizes="(max-width: 562px) 100vw, 562px" /></a><p id="caption-attachment-4563" class="wp-caption-text">Connect Pentaho with Gmail</p></div></li>
<li>Additionally, add the test user to the data source:
<div id="attachment_4564" style="width: 662px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-add-user-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4564" class="size-full wp-image-4564" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-add-user-data-source.png" alt="Gateway user to connect to REST API" width="652" height="408" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-add-user-data-source.png 652w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-add-user-data-source-300x188.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-add-user-data-source-436x272.png 436w" sizes="(max-width: 652px) 100vw, 652px" /></a><p id="caption-attachment-4564" class="wp-caption-text">Include user and permission to the gateway</p></div></li>
<li>In Pentaho, change the connection in the table input to connect to the Gateway:
<div id="attachment_4565" style="width: 1266px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4565" class="size-full wp-image-4565" src="https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection.png" alt="Use Pentaho Rest client to connect to Gamil" width="1256" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection.png 1256w, https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection-300x144.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection-768x369.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/08/gmail-connection-1024x492.png 1024w" sizes="(max-width: 1256px) 100vw, 1256px" /></a><p id="caption-attachment-4565" class="wp-caption-text">Pentaho Rest client to Gmail</p></div></li>
<li>Finally, in the table input add the following query:
<div id="attachment_4566" style="width: 555px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-query-gmail.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4566" class="wp-image-4566 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-query-gmail.png" alt="Query to get Gmail data and read REST API in Pentaho" width="545" height="212" srcset="https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-query-gmail.png 545w, https://zappysys.com/blog/wp-content/uploads/2018/08/pentaho-rest-api-query-gmail-300x117.png 300w" sizes="(max-width: 545px) 100vw, 545px" /></a><p id="caption-attachment-4566" class="wp-caption-text">Connect Pentaho to Gmail</p></div></li>
</ol>
<h3>Conclusions</h3>
<p>To conclude, we can say that it is simple to connect to the REST API using Pentaho with the help of ZappySys ODBC PowerPack. This tool allows to easily query REST API data like a simple SQL Query. If you like this tool you can<br />
download the <a href="https://zappysys.com/products/odbc-powerpack/purchase/" target="_blank" rel="noopener">ODBC PowerPack here</a>.</p>
<h3>References</h3>
<p>For more information, refer to the following links:</p>
<ul>
<li><a href="https://zappysys.com/products/odbc-powerpack/purchase/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a></li>
<li><a href="https://intellipaat.com/tutorial/pentaho-tutorial/introduction-to-pentaho/" target="_blank" rel="noopener">Introduction To Pentaho</a></li>
</ul>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/pentaho-read-rest-api-in-pentaho/">How to read REST API in Pentaho Kettle</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to connect Java to REST API (JSON / SOAP XML)</title>
		<link>https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Sun, 22 Jul 2018 18:50:09 +0000</pubDate>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[ODBC Gateway]]></category>
		<category><![CDATA[ODBC PowerPack]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest api]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4478</guid>

					<description><![CDATA[<p>Introduction In this new article, we will see how to connect Java to REST API using a simple connector. This ODBC driver allows connecting to REST API or a local file in Java using SQL queries. If you are familiar with SQL, you can easily access to REST API or JSON using simple SQL queries. This article mainly [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/">How to connect Java to REST API (JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png"><img loading="lazy" decoding="async" class=" wp-image-4482 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png" alt="Java logo used" width="61" height="61" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png 256w, https://zappysys.com/blog/wp-content/uploads/2018/07/Java-150x150.png 150w" sizes="(max-width: 61px) 100vw, 61px" /></a>In this new article, we will see how to connect Java to REST API using a simple connector. This ODBC driver allows connecting to REST API or a local file in Java using SQL queries. If you are familiar with SQL, you can easily access to REST API or JSON using simple SQL queries. This article mainly focus on JSON based REST API but techniques listed in this article is almost same for XML based API (e.g. SOAP Web Services).</p>
<h2>Requirements</h2>
<ol>
<li>First of all, we will require the <a href="https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-2017" target="_blank" rel="noopener">JDBC Driver for SQL Server</a>.</li>
<li>Secondly, we will require <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a>.</li>
<li>Also, we will require a Java IDE. We will use <a href="https://netbeans.org/community/releases/74/index.html" target="_blank" rel="noopener">Java NetBeans</a> for this.</li>
</ol>
<h2>Getting started</h2>
<p>First of all, we will create an ODBC connection with a Gateway to the SQL Server connector and then we will connect with Java code.</p>
<h3>Add ZappySys ODBC Driver to connect to REST API</h3>
<p>The ZappySys JSON Driver allows connecting to different resources like JSON files, REST API, OData, etc.</p>
<ol>
<li>First of all, in the ODBC Data Source Administrator, press add to add a new System Data Source:
<div id="attachment_4484" style="width: 600px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4484" class="size-full wp-image-4484" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png" alt="Include JSON driver in ODBC Data source" width="590" height="423" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png 590w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator-300x215.png 300w" sizes="(max-width: 590px) 100vw, 590px" /></a><p id="caption-attachment-4484" class="wp-caption-text">Add new ODBC driver</p></div></li>
<li>Secondly, select the ZappySys JSON Driver:
<div id="attachment_4485" style="width: 471px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4485" class="size-full wp-image-4485" src="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png" alt="Use ZappySys ODBC Driver" width="461" height="346" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png 461w, https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1-300x225.png 300w" sizes="(max-width: 461px) 100vw, 461px" /></a><p id="caption-attachment-4485" class="wp-caption-text">Select JSON driver in ODBC DS Administrator</p></div></li>
<li>Also, add this URL to the ZappySys JSON Driver:<br />
<pre class="crayon-plain-tag">https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json</pre>
<div id="attachment_4488" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4488" class="size-full wp-image-4488" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png" alt="URL for OData REST API" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4488" class="wp-caption-text">REST API ODBC URL</p></div></li>
</ol>
<h3>ZappySys Gateway to connect Java to REST API</h3>
<p>In order to connect Java to REST API, we will use a Gateway that is installed with the ZappySys ODBC PowerPack. This gateway uses a SQL Server connection. Let&#8217;s take a look at the steps.</p>
<ol>
<li>First of all, open the ZappysSys Data Gateway Configuration.</li>
<li>Secondly, press the add button and create a new data source named customer:
<div id="attachment_4490" style="width: 567px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4490" class="size-full wp-image-4490" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png" alt="Gateway add Data Source" width="557" height="209" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png 557w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway-300x113.png 300w" sizes="(max-width: 557px) 100vw, 557px" /></a><p id="caption-attachment-4490" class="wp-caption-text">Add new Data Source in ZappySys Gateway</p></div></li>
<li>Also, enable the custom data source and make sure to check the public option.</li>
<li>In addition, press the Edit and add the ODBC Data Source created in the Add ZappySys ODBC Driver to connect to REST API section:<br />
<pre class="crayon-plain-tag">&lt;strong&gt;NOTE:&lt;/strong&gt; Whenever possible use native driver option for better performance / security and ease of use.</pre>
<div style="width: 568px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full" src="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source.png?w=720&amp;ssl=1" alt="Native ODBC Driver" width="558" height="533" /><p class="wp-caption-text">Zappysys ODBC driver</p></div></li>
<li>Additionally, we will add a new user:
<div id="attachment_4492" style="width: 690px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4492" class="size-full wp-image-4492" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png" alt="Create a new user and add permission" width="680" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png 680w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-300x272.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></a><p id="caption-attachment-4492" class="wp-caption-text">Add the user to the data source gateway</p></div></li>
<li>Also, add the user to the data source:
<div id="attachment_4493" style="width: 690px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4493" class="size-full wp-image-4493" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png" alt="Data source with a new user" width="680" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png 680w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1-300x272.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></a><p id="caption-attachment-4493" class="wp-caption-text">Add user to the data source</p></div></li>
<li>Finally, check the default port in the general tab. By default this value is 5000:
<div id="attachment_4495" style="width: 572px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4495" class="size-full wp-image-4495" src="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png" alt="Port 5000 in the default gateway" width="562" height="539" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png 562w, https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port-300x288.png 300w" sizes="(max-width: 562px) 100vw, 562px" /></a><p id="caption-attachment-4495" class="wp-caption-text">Default gateway with port 5000</p></div></li>
</ol>
<p>&nbsp;</p>
<h3>Connect Java to REST API</h3>
<ol>
<li>First of all, we will first try to connect to the following URL:<br />
<pre class="crayon-plain-tag">https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json</pre>
</li>
<li>Secondly, we will get the countries and the sum or quantity orders using the following code:<br />
<pre class="crayon-plain-tag">package padaone;

import java.sql.*;

public class zappy {

	public static void main(String[] args) {
		
		// Create a variable for the connection string.
		String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;user=test;password=test";

		// Declare the JDBC objects.
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
        	try {
        		// Establish the connection.
        		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            		con = DriverManager.getConnection(connectionUrl);
            
            		// Create and execute an SQL statement that returns some data.
            		String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " 
	+ "FROM value " 
	+ "GROUP BY Country " 
	+ "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);
            
            		// Iterate through the data in the result set and display it.
            		while (rs.next()) {
            			System.out.println(rs.getString(1) + " " + rs.getString(2));
            		}
        	}
        
		// Handle any errors that may have occurred.
		catch (Exception e) {
			e.printStackTrace();
		}

		finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}
	}
}</pre>
</li>
<li>In addition, in the project, go to libraries, right click and select the option to add JAR or folder and select the sqljdbc42.jar. This jar file is used to connect to SQL Server. The ZappySys ODBC PowerPack uses the SQL Server JDBC connector with a gateway to connect to REST API or JSON files:
<div id="attachment_4499" style="width: 324px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4499" class="size-full wp-image-4499" src="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png" alt="Add library in NetBeans" width="314" height="449" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png 314w, https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file-210x300.png 210w" sizes="(max-width: 314px) 100vw, 314px" /></a><p id="caption-attachment-4499" class="wp-caption-text">Add SQL Server jar file</p></div></li>
<li>Also, we will need to add the sqljdb4.2.jar and the sqljdbc_auth.dll in the <strong>C:/Windows/System32</strong> and the path where the JDK is installed (in this example <strong>C:/Program Files/Java/jdk1.8.0_171/bin)</strong>.</li>
<li>Finally, run the code and you will visualize the query results of the REST API:
<div id="attachment_4501" style="width: 383px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4501" class="size-full wp-image-4501" src="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png" alt="Show REST API results in Java" width="373" height="264" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png 373w, https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results-300x212.png 300w" sizes="(max-width: 373px) 100vw, 373px" /></a><p id="caption-attachment-4501" class="wp-caption-text">REST API results in Java</p></div></li>
</ol>
<h3>Explanation of the code to Connect Java to REST API</h3>
<p>Previously, we run the code to query REST API data in Java. Now we will explain the code.</p>
<ol>
<li>First of all, we will import the java.sql to connect to SQL Server using Java:<br />
<pre class="crayon-plain-tag">import java.sql.*;</pre>
</li>
<li>Secondly, we will create a connection to the ZappySys Gateway. Using the port 5000 and we are using the data source and user created in the Add ZappySys ODBC Driver to connect to REST API:<br />
<pre class="crayon-plain-tag">String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;
user=test;password=test";</pre>
</li>
<li>Also, we will set the variables to null to initialize them:<br />
<pre class="crayon-plain-tag">Connection con = null;
Statement stmt = null;
ResultSet rs = null;</pre>
</li>
<li>In addition, we will connect to the JDBC SQL driver:<br />
<pre class="crayon-plain-tag">Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);</pre>
</li>
<li>Additionally, we will send a query to the URL and get the country and the sum of price multiplied by quantity, group by country:<br />
<pre class="crayon-plain-tag">String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " 
	+ "FROM value " 
	+ "GROUP BY Country " 
	+ "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);</pre>
</li>
<li>Next, we will print the results of the query:<br />
<pre class="crayon-plain-tag">while (rs.next()) {
   System.out.println(rs.getString(1) + " " + rs.getString(2));
}</pre>
</li>
<li>Finally, we will close all the connections:<br />
<pre class="crayon-plain-tag">finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}</pre>
&nbsp;</li>
</ol>
<h3>How to connect to multiple JSON files</h3>
<p>The ZappySys ODBC PowerPack can be used to easily read local JSON files in Java and query using SQL with SELECT, WHERE, GROUP BY, HAVING and other SQL clauses. For more information, refer to this <a href="https://zappysys.com/onlinehelp/odbc-powerpack/index.htm#page=json-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">link</a>.</p>
<ol>
<li>The following code will list the files and the content of the JSON files:<br />
<pre class="crayon-plain-tag">package padaone;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class localfile {
    public static void main(String[] args) {
        File directory = new File ("C:\\temp");
        File[] list = directory.listFiles();
        
        printNames(list);	
    }

    private static void printNames(File[] list) {
        for(int i =0;i&lt;list.length;i++){
            if(list[i].isFile()){
                System.out.println(list[i].getName());

                
                showContent(list[i]);
                
            }
        }
    }

    private static void showContent(File file) {
      
        // Create a variable for the connection string.
        String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;user=test;password=test";

        // Declare the JDBC objects.
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;

        try {
                // Establish the connection.
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                con = DriverManager.getConnection(connectionUrl);

                // Create and execute an SQL statement that returns some data.
                String SQL = "SELECT * FROM $ WITH (SRC='C:\\temp\\"+file.getName()+"')";
                stmt = con.createStatement();
                rs = stmt.executeQuery(SQL);

                // Iterate through the data in the result set and display it.
                while (rs.next()) {
                        System.out.println(rs.getString(1) + " " + rs.getString(2));//+ " " + rs.getString(3)+ " " + rs.getString(4)+ " " + rs.getString(5)+ " " + rs.getString(6));
                }
        }

        // Handle any errors that may have occurred.
        catch (Exception e) {
                e.printStackTrace();
        }

        finally {
                if (rs != null) try { rs.close(); } catch(Exception e) {}
                if (stmt != null) try { stmt.close(); } catch(Exception e) {}
                if (con != null) try { con.close(); } catch(Exception e) {}
        }
	
    }

}</pre>
</li>
<li>The JSON files are the following:<br />
<pre class="crayon-plain-tag">example_1.json

[{
  "id": 1,
  "first_name": "Jeanette",
  "last_name": "Penddreth",
  "email": "jpenddreth0@census.gov",
  "gender": "Female",
  "ip_address": "26.58.193.2"
}, {
  "id": 2,
  "first_name": "Giavani",
  "last_name": "Frediani",
  "email": "gfrediani1@senate.gov",
  "gender": "Male",
  "ip_address": "229.179.4.212"
}, {
  "id": 3,
  "first_name": "Noell",
  "last_name": "Bea",
  "email": "nbea2@imageshack.us",
  "gender": "Female",
  "ip_address": "180.66.162.255"
}, {
  "id": 4,
  "first_name": "Willard",
  "last_name": "Valek",
  "email": "wvalek3@vk.com",
  "gender": "Male",
  "ip_address": "67.76.188.26"
}]

example_2.json

{
    "quiz": {
        "sport": {
            "q1": {
                "question": "Which one is correct team name in NBA?",
                "options": [
                    "New York Bulls",
                    "Los Angeles Kings",
                    "Golden State Warriros",
                    "Huston Rocket"
                ],
                "answer": "Huston Rocket"
            }
        },
        "maths": {
            "q1": {
                "question": "5 + 7 = ?",
                "options": [
                    "10",
                    "11",
                    "12",
                    "13"
                ],
                "answer": "12"
            },
            "q2": {
                "question": "12 - 8 = ?",
                "options": [
                    "1",
                    "2",
                    "3",
                    "4"
                ],
                "answer": "4"
            }
        }
    }
}</pre>
</li>
<li>Finally, if everything is fine, you will be able to see the file names<br />
and the content:</p>
<div id="attachment_4505" style="width: 886px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4505" class="size-full wp-image-4505" src="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png" alt="JSON files read in Java" width="876" height="246" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png 876w, https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java-300x84.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java-768x216.png 768w" sizes="(max-width: 876px) 100vw, 876px" /></a><p id="caption-attachment-4505" class="wp-caption-text">Read JSON files in Java</p></div></li>
</ol>
<h3>How to connect Java to REST API Gmail</h3>
<p>Connect Java to Google, Facebook, OneDrive or other REST API tools is a straightforward process using the ZappySys ODBC Driver. You just need to create the Data Source in ODBC and then create a ZappySys Gateway, the rest is simple in Java. Let&#8217;s take a look at an example.</p>
<ol>
<li>First of all, we will create a new Data source in the Windows ODBC Data<br />
Source Administrator. We will create a new ZappySys JSON Driver and add the following link:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/messages/</pre>
</li>
<li>Secondly, select the OAuth connection type and $.messages[*] in the<br />
filter and press the Click to Configure link:</p>
<div id="attachment_4507" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4507" class="size-full wp-image-4507" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png" alt="Create ODBC connection to Gmail" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4507" class="wp-caption-text">Setup ODBC configuration to URL</p></div></li>
<li>Also, in the OAuth parameters link, select the Google OAuth Provider.</li>
<li>In addition in scopes write the scope https://mail.google.com:
<div id="attachment_4508" style="width: 596px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4508" class="size-full wp-image-4508" src="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png" alt="Use Java to connect to Gmail" width="586" height="493" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png 586w, https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API-300x252.png 300w" sizes="(max-width: 586px) 100vw, 586px" /></a><p id="caption-attachment-4508" class="wp-caption-text">Rest API connect to Gmail</p></div></li>
<li>Additionally, in the preview tab, you can generate your queries and save<br />
your Data Source:</p>
<div id="attachment_4510" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4510" class="size-full wp-image-4510" src="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png" alt="Create REST API gmail queries" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4510" class="wp-caption-text">Connect Java to REST API</p></div></li>
<li>Next, open your ZappySys Data Gateway. We will create a new Data Source<br />
named gm:</p>
<div id="attachment_4511" style="width: 570px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4511" class="wp-image-4511 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png" alt="Use gateway to connect Java to REST API" width="560" height="280" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png 560w, https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source-300x150.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></a><p id="caption-attachment-4511" class="wp-caption-text">Add Gmail Data Source</p></div></li>
<li>Also, we will associate the ODBC Data Source with the Gateway Data Source. Make sure to add the test user to the Gateway data source:
<div id="attachment_4513" style="width: 573px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4513" class="size-full wp-image-4513" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png" alt="Add ODBC data source to gateway" width="563" height="539" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png 563w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source-300x287.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></a><p id="caption-attachment-4513" class="wp-caption-text">Include the data source for the ODBC</p></div></li>
<li>Finally, you can run this code. The code in Java will connect to the Gateway data source using the port 5000 and the Gateway user and password. The query will show the Gmail message ids:<br />
<pre class="crayon-plain-tag">package padaone;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class gmail {
    public static void main(String[] args) {
		
		// Create a variable for the connection string.
		String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=gm;user=test;password=test";

		// Declare the JDBC objects.
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
        	try {
        		// Establish the connection.
        		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            		con = DriverManager.getConnection(connectionUrl);
            
            		// Create and execute an SQL statement that returns some data.
            		String SQL = "SELECT id FROM [_root_]";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);
            
            		// Iterate through the data in the result set and display it.
            		while (rs.next()) {
            			System.out.println(rs.getString(1));
            		}
        	}
        
		// Handle any errors that may have occurred.
		catch (Exception e) {
			e.printStackTrace();
		}

		finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}
	}
}</pre>
</li>
<li>You can find your message id in Google by clicking your messages:
<div id="attachment_4514" style="width: 392px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4514" class="size-full wp-image-4514" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png" alt="Using Java to get Gmail info" width="382" height="238" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png 382w, https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id-300x187.png 300w" sizes="(max-width: 382px) 100vw, 382px" /></a><p id="caption-attachment-4514" class="wp-caption-text">Display Gmail information in Java</p></div></li>
</ol>
<h2>ZappySys JSON /REST API Driver Query Examples</h2>
<p>Reading from XML files or API can be done using the same way as previous sections except you have to use ZappySys XML Driver. Read help file here to <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/json-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">see json query examples</a>.</p>
<h2>ZappySys XML / SOAP Driver Query Examples</h2>
<p>Reading from XML files or API can be done using the same way as previous sections except you have to use ZappySys XML Driver. Read help file here to <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/xml-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">see xml query examples</a>.</p>
<h2>Calling XML SOAP Web Service in JAVA</h2>
<p>So far we have looked at examples to consume data using JSON driver. Now lets look at an example, to call XML SOAP Web Service in JAVA.</p>
<div class="content_block" id="custom_post_widget-3870">To call SOAP API you need to know Request XML Body Structure. If you are not sure how to create SOAP Request body then no worries. <a href="https://zappysys.com/blog/calling-soap-web-service-in-ssis-xml-source/" target="_blank" rel="noopener">Check this article</a> to learn how to generate SOAP Request body using the Free tool <a href="https://www.soapui.org/downloads/latest-release.html" target="_blank" rel="noopener">SoapUI</a>. Basically, you have to use SoapUI to generate Request XML and after that, you can replace parameters as needed in the generated body.
<h3>What is SOAP Web Service?</h3>
If you are new to SOAP Web Service sometimes referred as XML Web Service then please read some concept about SOAP Web service standard <a href="https://msdn.microsoft.com/en-us/library/ms996507.aspx?f=255&amp;MSPPError=-2147217396" target="_blank" rel="noopener">from this link</a>

There are two important aspects in SOAP Web service.
<ol>
 	<li>Getting WSDL file or URL</li>
 	<li>Knowing exact Web Service URL</li>
</ol>
<h3>What is WSDL</h3>
In very simple term WSDL (often pronounced as whiz-dull) is nothing but a document which describes Service metadata (e.g. Functions you can call, Request parameters, response structure etc). Some service simply give you WSDL as xml file you can download on local machine and then analyze or sometimes you may get direct URL (e.g. http://api.mycompany.com/hr-soap-service/?wsdl )
<h3>Example SQL Query for SOAP API call using ZappySys XML Driver</h3>
Here is an example SQL query you can write to call SOAP API. If you not sure about many details then check next few sections on how to use XML Driver User Interface to build desired SQL query to POST data to XML SOAP Web Service without any coding.
<pre class="lang:tsql decode:true">SELECT * FROM $
WITH(
	 Src='http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx'
	,DataConnectionType='HTTP'
	,CredentialType='Basic' --OR SoapWss
	,SoapWssPasswordType='PasswordText'
	,UserName='myuser'
	,Password='pass$$w123'
	,Filter='$.soap:Envelope.soap:Body.GetHolidaysAvailableResponse.GetHolidaysAvailableResult.HolidayCode[*]'
	,ElementsToTreatAsArray='HolidayCode'	
	,RequestMethod='POST'	
	,Header='Content-Type: text/xml;charset=UTF-8 || SOAPAction: "http://www.holidaywebservice.com/HolidayService_v2/GetHolidaysAvailable"'
	,RequestData='
&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hol="http://www.holidaywebservice.com/HolidayService_v2/"&gt;
   &lt;soapenv:Header/&gt;
   &lt;soapenv:Body&gt;
      &lt;hol:GetHolidaysAvailable&gt;
         &lt;!--type: Country - enumeration: [Canada,GreatBritain,IrelandNorthern,IrelandRepublicOf,Scotland,UnitedStates]--&gt;
         &lt;hol:countryCode&gt;UnitedStates&lt;/hol:countryCode&gt;
      &lt;/hol:GetHolidaysAvailable&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;'
)</pre>
Now let's look at steps to create SQL query to call SOAP API. Later we will see how to generate code for your desired programming language (e.g. C# or SQL Server)
<h3>Video Tutorial - Introduction to SOAP Web Service and SoapUI tool</h3>
Before we dive into details about calling SOAP API using ZappySys XML Driver, lets first understand what is SOAP API and how to create SOAP requests using SoapUI tool. You will learn more about this process in the later section. The video contains some fragment about using SOAP API in SSIS but just ignore that part because we will be calling Soap API using ZappySys ODBC Driver rather than SSIS Components.

&nbsp;

<iframe loading="lazy" width="560" height="315" src="https://www.youtube.com/embed/d_x5bgGjg0Y?rel=0&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen="allowfullscreen" data-mce-fragment="1"></iframe>
<h3>Using SoapUI to test SOAP API call / Create Request Body XML</h3>
Assuming you have downloaded and installed <a href="https://www.soapui.org/downloads/latest-release.html" target="_blank" rel="noopener">SoapUI from here</a>, now we are ready to use WSDL for your SOAP Web Service Calls. If you do not have WSDL file or URL handy then contact your API provider (sometimes you just have to add <strong>?wsdl </strong>at the end of your Service URL to get WSDL so try that. Example: http://mycompany/myservice?wsdl ).

If you don't know what is WSDL then in short, WSDL is <strong>Web service Description Language</strong> (i.e. XML file which describes your SOAP Service). WSDL helps to craft SOAP API request Body for ZappySys XML Driver. So Let's get started.
<ol>
 	<li>Open SoapUI and click SOAP button to create new SOAP Project</li>
 	<li>Enter WSDL URL or File Path of WSDLFor example WSDL for our sample service can be accessed via this URL
<pre class="lang:default highlight:0 decode:true">http://www.dneonline.com/calculator.asmx?wsdl</pre>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-import-wsdl-new-soapui-project.png"><img loading="lazy" decoding="async" class="size-full wp-image-3871" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-14.png" alt="Create new SOAP API Project in SoapUI tool for SOAP API Testing" width="486" height="349" /></a>
<div style="margin-bottom: 1em;">Create new SOAP API Project in SoapUI tool for SOAP API Testing</div></li>
 	<li>Once WSDL is loaded you will see possible operations you can call for your SOAP Web Service.</li>
 	<li>If your web service requires credentials then you have to configure it. There are two common credential types for public services (<strong>SOAP WSS</strong> or <strong>BASIC</strong> )
<ol>
 	<li>
<div style="margin-bottom: 1em;">To use <strong>SOAP WSS Credentials</strong> select request node and enter UserId, Password, and <strong>WSS-PasswordType</strong> (PasswordText or PasswordHash)</div>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-pass-soap-wss-credentials-userid-password.png"><img loading="lazy" decoding="async" class="size-full wp-image-3872 alignnone" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-2.png" alt="Configure SOAP WSS Credentials for SoapUI (SOAP API Testing Tool)" width="294" height="544" /></a>
<div style="display: block;">Configure SOAP WSS Credentials for SoapUI (SOAP API Testing Tool)</div></li>
 	<li>To use <strong>BASIC Auth</strong> Credentials select request node and double-click it. At the bottom click on Auth (Basic) and From Authorization dropdown click Add New and Select Basic.<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-pass-basic-authentication-userid-password.png"><img loading="lazy" decoding="async" class="size-full wp-image-3873" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-2.png" alt="Configure Basic Authorization for SoapUI (SOAP API Testing Tool)" width="616" height="653" /></a>
<div style="margin-bottom: 1em;">Configure Basic Authorization for SoapUI (SOAP API Testing Tool)</div></li>
</ol>
</li>
 	<li>Now you can test your request first Double-click on the request node to open request editor.</li>
 	<li>Change necessary parameters, remove optional or unwanted parameters. If you want to regenerate request you can click on <strong>Recreate default request toolbar icon</strong>.
<a href="https://zappysys.com/blog/wp-content/uploads/2016/06/create-soap-request-with-optional-parameters-soapui.png"><img loading="lazy" decoding="async" class="size-full wp-image-2812" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-4.png" alt="Create SOAP Request XML (With Optional Parameters)" width="807" height="315" /></a>
<div style="margin-bottom: 1em;">Create SOAP Request XML (With Optional Parameters)</div></li>
 	<li>Once your SOAP Request XML is ready, <strong>Click the Play button</strong> in the toolbar to execute SOAP API Request and Response will appear in Right side panel.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soapui-test-soap-api-request-response-edit-xml-body.png"><img loading="lazy" decoding="async" class="size-full wp-image-3874" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-5.png" alt="Test SOAP API using SoapUI Tool (Change Default XML Body / Parameters, Execute and See Response)" width="1216" height="511" /></a>
Test SOAP API using SoapUI Tool (Change Default XML Body / Parameters, Execute and See Response)</li>
</ol>
<h3>Create DSN using ZappySys XML Driver to call SOAP API</h3>
Once you have tested your SOAP API in SoapUI tool, we are ready to use ZappySys XML driver to call SOAP API in your preferred BI tool or Programming language.
<ol>
 	<li>First open <strong>ODBC Data Sources</strong> (search ODBC in your start menu or go under ZappySys &gt; ODBC PowerPack &gt; <strong>ODBC 64 bit</strong>)</li>
 	<li>Goto <strong>System DSN</strong> Tab (or User DSN which is not used by Service account)</li>
 	<li>Click <strong>Add</strong> and Select ZappySys XML Driver
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/zappysys-odbc-xml-soap-api-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3875" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-6.png" alt="ZappySys ODBC Driver for XML / SOAP API" width="593" height="459" /></a>
ZappySys ODBC Driver for XML / SOAP API</li>
 	<li>Configure API URL, Request Method and Request Body as below
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-web-service-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3876" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-7.png" alt="ZappySys XML Driver - Calling SOAP API - Configure URL, Method, Body" width="916" height="874" /></a>
ZappySys XML Driver - Calling SOAP API - Configure URL, Method, Body</li>
 	<li><strong>(This step is Optional)</strong> If your SOAP API requires credentials then Select Connection Type to HTTP and configure as below.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soap-api-call-credential-basic-soap-wss-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3877" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-8.png" alt="ZappySys XML Driver - Configure SOAP WSS Credentials or Basic Authorization (Userid, Password)" width="564" height="483" /></a>
<div style="display: block;">ZappySys XML Driver - Configure SOAP WSS Credentials or Basic Authorization (Userid, Password)</div></li>
 	<li>Configure-Request Headers as below (You can get it from Request &gt; Raw tab from SoapUI after you test the request by clicking the Play button)
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/set-soap-api-request-headers-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3881" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-9.png" alt="Configure SOAP API Request Headers - ZappySys XML Driver" width="1009" height="747" /></a>
Configure SOAP API Request Headers - ZappySys XML Driver</li>
 	<li>Once credentials entered you can select Filter to extract data from the desired node. Make sure to select array node (see special icon) or select the node which contains all necessary columns if you don't have array node.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soap-api-query-select-filter-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3882" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-10.png" alt="Select Filter - Extract data from nested XML / SOAP API Response (Denormalize Hierarchy)" width="809" height="594" /></a>
Select Filter - Extract data from nested XML / SOAP API Response (Denormalize Hierarchy)</li>
 	<li>If prompted select yes to treat selected node as Array (This is helpful when you expect one or more record for selected node)
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/xml-api-array-handling-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3883" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-11.png" alt="Treat selected node as XML Array Option for SOAP API Response XML" width="655" height="572" /></a>
Treat selected node as XML Array Option for SOAP API Response XML</li>
</ol>
<h3>Preview SOAP API Response / Generate SQL Code for SOAP API Call</h3>
Once you configure settings for XML Driver now you can preview data or generate example code for desired language (e.g. C#, Python, Java, SQL Server).

Go to Preview tab and you will see default query generated based on settings you entered in previous sections. Attributes listed in WITH clause are optional. If you omit attribute in WITH clause it will use it from Properties tab.
<h3>Preview Data</h3>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-web-service-zappysys-xml-api-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3884" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-12.png" alt="Preview SOAP API Response in ZappySys XML Driver" width="808" height="780" /></a>
Preview SOAP API Response in ZappySys XML Driver
<h3>Generate Code Option</h3>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/zappysys-driver-code-generator.png"><img loading="lazy" decoding="async" class="size-full wp-image-3885" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-13.png" alt="Generate Example Code for ZappySys Driver" width="572" height="618" /></a>
<div style="display: block;">Generate Example Code for ZappySys Driver</div></div>
<h2>POST data to REST API URL from file in JAVA</h2>
<p>Above example was POST data to API URL but what if your Request Body is large and you have saved that to file? Well here is the way to get your request body from a file (Use @ symbol before path).</p><pre class="crayon-plain-tag">SELECT * FROM $
WITH 
(METHOD='POST' 
,HEADER='Content-Type:text/plain || x-hdr1:AAA'
,SRC='http://httpbin.org/post'
,BODY='@c:\files\dump.xml'
,IsMultiPart='True'
)</pre><p>
&nbsp;</p>
<h2>REST API Pagination in JAVA</h2>
<div class="content_block" id="custom_post_widget-3892"><div style="margin-bottom: 1em;">Even we set up ODBC Data Source to get the data, it may not be enough. Usually, if you are getting a huge data set from API provider, it won't give it to you in one HTTP response. Instead, it gives back only a subset of data and provides a mechanism for data pagination. The good news is that <em>ZappySys ODBC Driver</em> includes many options to cover virtually any pagination method.</div>
<div><span style="font-size: 16px;">Below you will find a few examples of API pagination. If you need something more sophisticated check the below link (the article was written for SSIS PowerPack but UI options and concepts apply to ODBC Driver too):</span></div>
<div style="margin-bottom: 1em;"><a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/</a></div>
<h3>Paginate by Response Attribute</h3>
This example shows how to paginate API calls where you need to paginate until the last page detected. In this example, next page is indicated by some attribute called nextlink (found in response). If this attribute is missing or null then it stops fetching the next page.
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH(
SRC=@'https://zappysys.com/downloads/files/test/pagination_nextlink_inarray_1.json'
,NextUrlAttributeOrExpr = '$.nextlink'  --keep reading until this attribute is missing. If attribute name contains dot then use brackets like this $.['my.attr.name']
)</pre>
<h3>Paginate by URL Parameter (Loop until certain StatusCode)</h3>
This example shows how to paginate API calls where you need to pass page number via URL. The driver keeps incrementing page number and calls next URL until the last page detected (401 error). There are few ways to indicate the last page (e.g. By status code, By row count, By response size). If you don't specify end detection then it will use the default (i.e. No records found).
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH (
SRC=@'https://zappysys.com/downloads/files/test/page-xml.aspx?page=1&amp;mode=DetectBasedOnResponseStatusCode'
,PagingMode='ByUrlParameter'
,PagingByUrlAttributeName='page'
,PagingByUrlEndStrategy='DetectBasedOnResponseStatusCode'
,PagingByUrlCheckResponseStatusCode=401
,IncrementBy=1
)</pre>
<h3>Paginate by URL Path (Loop until no record)</h3>
This example shows how to paginate API calls where you need to pass page number via URL Path. The driver keeps incrementing page number and calls next URL until the last page is detected. There are few ways to indicate the last page (e.g. By status code, By row count, By response size). If you don't specify end detection then it will use the default (i.e. No records found).
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH (
SRC=@'https://zappysys.com/downloads/files/test/cust-&lt;%page%&gt;.xml'
,PagingMode='ByUrlPath'
,PagingByUrlAttributeName='&lt;%page%&gt;'
,PagingByUrlEndStrategy='DetectBasedOnRecordCount'
,IncrementBy=1
)</pre>
<h3>Paginate by Header Link (RFC 5988)</h3>
API like GitHub / Wordpress use Next link in Headers (<a href="https://tools.ietf.org/html/rfc5988" target="_blank" rel="noopener">RFC 5988</a>)
<pre class="lang:default decode:true ">SELECT * FROM $
LIMIT 25
WITH(
	 Src='https://wordpress.org/news/wp-json/wp/v2/categories?per_page=10'
	,PagingMode='ByResponseHeaderRfc5988'
	,WaitTimeMs='200' --//wait 200 ms after each request
)</pre>
&nbsp;</div>
<h2>Error Handling in REST API / SOAP</h2>
<div class="content_block" id="custom_post_widget-3894">Sometimes errors occur... they just do and there is nothing you can do! Or can you? Actually, in ODBC PowerPack you can handle them in two ways.
<h3>METHOD 1 - Using Error Handling Options</h3>
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-3949" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-error-handling-1.png" alt="" width="668" height="702" />
<h4>When to use?</h4>
You may want to use them when your source is a resource located on the Internet; e.g. a file on a website, a file on an FTP server or just a plain API HTTP response. By default, when a remote server returns an error, data retrieval is stopped, an error is raised and no data is given back to you. This might not be always desirable.
<h4>Scenario 1</h4>
Imagine a scenario, that there is a web server which each day at 12 AM releases a new JSON file with that day's date as filename, e.g. <span style="text-decoration: underline;"><em>http://www.some-server.com/data/2018-06-20.json</em></span>. And, of course, you want to download it and use it daily in your Power BI report. But you have a problem: Power BI report data sources are refreshed each hour and you may get <a href="https://en.wikipedia.org/wiki/HTTP_404" target="_blank" rel="noopener">HTTP 404 status code</a> (no file was found) when a file is not released yet. Which consequentially means other data sources won't be updated as well and you will see old and cached data on the report. That's where you could use <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue on any error</span></strong> or <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue when Url is invalid or missing (404 Errors)</span></strong> to avoid an error being raised and let other data sources to be updated.
<h4>Scenario 2</h4>
Another scenario is when you expect a web server to raise some kind of HTTP error when accessing a URL. You don't want ODBC Data Source to raise an error but instead, you want to get response data. That's where you can use <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue on any error</span></strong> or alike together with  <strong><span class="lang:default highlight:0 decode:true crayon-inline">Get response data on error</span></strong> to continue on an error and get the data:

<img loading="lazy" decoding="async" class="alignnone wp-image-3961 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error.png" alt="" width="547" height="235" srcset="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error.png 547w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error-300x129.png 300w" sizes="(max-width: 547px) 100vw, 547px" />
<h3>METHOD 2 - Using Connection [Retry Settings]</h3>
Another scenario you may run into is a buggy web server. You ask it to give you some file or data and it, like a snotty kid, just doesn't give it to you! You have to ask twice or thrice before it does its job. If that's the case, you have to retry HTTP requests using <em>Connection</em>:

<img loading="lazy" decoding="async" class="alignnone wp-image-3963 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-error-handling-3.png" alt="" width="671" height="572" /></div>
<h2>REST API / SOAP Connection Types in JAVA (OAuth / HTTP)</h2>
<div class="content_block" id="custom_post_widget-3896"><div style="margin-bottom: 1em;">If you need to authenticate or authorize your user to access a web resource, you will need to use one of the <em>Connections:</em></div>
<ul>
 	<li>HTTP</li>
 	<li>OAuth</li>
</ul>
<img loading="lazy" decoding="async" class="wp-image-4078 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252.png" alt="ZappySys XML Driver - HTTP and OAuth Connection Types" width="577" height="302" srcset="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252.png 577w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252-300x157.png 300w" sizes="(max-width: 577px) 100vw, 577px" />
<h3>HTTP Connection</h3>
<div style="margin-bottom: 1em;">Use <em>HTTP Connection</em> for simple Windows, Basic, NTLM or Kerberos authentication. Just fill in a username and a password and you are good to go!</div>
<div style="margin-bottom: 1em;">You can also use <em>HTTP Connection</em> for more sophisticated authentication like:</div>
<ul>
 	<li><strong>SOAP WSS</strong> (when accessing a SOAP WebService)</li>
 	<li><strong>Static Token / API Key</strong> (when need to pass an API key in HTTP header)</li>
 	<li><strong>Dynamic Token</strong> (same as Static Token method except that each time you need to log in and retrieve a fresh API key)</li>
 	<li><strong>JWT Token</strong> (As per RFC 7519)</li>
</ul>
<img loading="lazy" decoding="async" class="alignnone wp-image-4091 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-connection-type-1.png" alt="" width="622" height="570" />
<h3>OAuth</h3>
If you are trying to access REST API resource, it is a huge chance, you will need to use <em>OAuth Connection</em>. <a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">Read this article</a> to understand how OAuth authentication and authorization works and how to use it (article originally was written for <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a>, but the concepts and UI stay the same): <br/>
<a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/</a>
<img loading="lazy" decoding="async" class="alignnone size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-connection-type-2.png" width="721" height="708" /></div>
<h2>Performance consideration for Web API Calls</h2>
<div class="content_block" id="custom_post_widget-4455">While calling APIs you may face some performance issues. There are a few tips you can consider to speed up things.
<h4><span style="font-size: 14pt;"><strong>Use Server-side filtering if possible in URL or Body Parameters</strong></span></h4>
Many API supports filtering your data by URL parameters or via Body. Whenever possible try to use such features.  Here is an example of <a href="http://www.odata.org/getting-started/basic-tutorial/" target="_blank" rel="noopener">odata API</a>, In the below query the first query is faster than the second query because in the first query we filter at the server.
<pre class="lang:tsql decode:true">SELECT * FROM value
WITH(
	 Src='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json&amp;$filter=Country eq ''USA'''
	,DataFormat='Odata'
)

-- Slow query - Client-side filtering
SELECT * FROM value
WHERE Country ='USA'
WITH(
	 Src='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json'
	,DataFormat='Odata'
)</pre>
<h4><span style="font-size: 14pt;"><strong>Avoid Special features in SQL Query (e.g. WHERE, Group By, Order By)</strong></span></h4>
ZappySys API engine triggers client-side processing if special features are used in Query. Following SQL Features will trigger Client-Side processing which is several times slower than server-side processing. So always try to use simple query (Select col1, col2 .... from mytable )
<ul>
 	<li>WHERE Clause</li>
 	<li>GROUP BY Clause</li>
 	<li>HAVING Clause</li>
 	<li>ORDER BY</li>
 	<li>FUNCTIONS (e.g. Math, String, DateTime, Regex... )</li>
</ul>
LIMIT clause does not trigger client-side processing.
<h4><span style="font-size: 14pt;"><strong>Consider using pre-generated Metadata / Cache File</strong></span></h4>
Use META option in WITH Clause to use static metadata (Pre-Generated)There are two more options to speedup query processing time. Check <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/" target="_blank" rel="noopener">this article</a> for details.
<ol>
 	<li>
<pre class="lang:default decode:true">select * from value WITH( meta='c:\temp\meta.txt' )
--OR--
select * from value WITH( meta='my-meta-name' )
--OR--
select * from value WITH( meta='[ {"Name": "col1",&amp;nbsp;"Type": "String", Length: 100},&amp;nbsp;{"Name": "col2",&amp;nbsp;"Type": "Int32"} ...... ]' )</pre>
</li>
 	<li>Enable Data Caching Options (Found on <strong>Property Grid</strong> &gt; <strong>Advanced</strong> Mode Only )</li>
</ol>
<h4><span style="font-size: 14pt;"><strong>Consider using Metadata / Data Caching Option</strong></span></h4>
ZappySys API drivers support Caching Metadata and Data rows to speed up query processing. If your data doesn't change often then you can enable this option to speed up processing significantly.

Check <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/" target="_blank" rel="noopener">this article</a> for details how to enable Data cache / metadata cache feature for datasource level or query level.

To define cache option at query level you can use like below.
<pre class="">SELECT * FROM $
WITH 
(  SRC='https://myhost.com/some-api'
  ,CachingMode='All'  --cache metadata and data rows both
  ,CacheStorage='File' --or Memory
  ,CacheFileLocation='c:\temp\myquery.cache'
  ,CacheEntryTtl=300 --cache for 300 seconds
)
</pre>
&nbsp;

&nbsp;
<h4><strong><span style="font-size: 14pt;">Use --FAST Option to enable Stream Mode</span></strong></h4>
ZappySys JSON / XML drivers support <strong>--FAST</strong> suffix for Filter. By using this suffix after Filter driver enables Stream Mode, <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/#Reading_Large_Files_Streaming_Mode_for_XML_JSON" target="_blank" rel="noopener">Read this article</a> to understand how this works.
<pre class="lang:default decode:true">SELECT * FROM $ 
LIMIT 10 --//add this just to test how fast you can get 10 rows
WITH(
  Filter='$.LargeArray[*]--FAST' --//Adding --FAST option turn on STREAM mode (large files)
 ,SRC='https://zappysys.com/downloads/files/test/large_file_100k_largearray_prop.json.gz'
 --,SRC='c:\data\large_file.json.gz'
 ,IncludeParentColumns='False'  --//This Must be OFF for STREAM mode (read very large files)
 ,FileCompressionType='GZip' --Zip or None (Zip format only available for Local files)
)</pre>
&nbsp;</div>
<h2>Other considerations for Web API calls in JAVA</h2>
<div class="content_block" id="custom_post_widget-3901">There are few settings you can coder while calling Web API
<h3><strong>API Limit / Throttling</strong></h3>
While calling public API or other external web services one important aspect you have to check,  how many requests are allowed by your API. Especially when you use API pagination options to pull many records you have to slow down based on API limits. For example, your API may allow you only 5 requests per second. Use Throttling Tab on Driver UI to set delay after each request.
<h3><strong>2D Array Transformation</strong></h3>
If you are using JSON or XML API Driver then possible you may have to transform your data using 2D array transformation feature. <a href="https://zappysys.com/blog/parse-multi-dimensional-json-array-ssis/" target="_blank" rel="noopener">Check this link</a> for more information.

&nbsp;</div>
<h2></h2>
<h3>Conclusion</h3>
<p>To conclude, in this tutorial, we learned how to access the REST API using Java. We created a ZappySys ODBC connection and then used a ZappySys Gateway to connect to it.</p>
<h3>References</h3>
<ul>
<li><a href="https://zappysys.com/products/odbc-powerpack/download/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a></li>
<li><a href="https://zappysys.com/onlinehelp/odbc-powerpack/index.htm#page=odbc-integration-programming-java.htm" target="_blank" rel="noopener">Java example ZappySys ODBC PowerPack</a></li>
<li><a href="http://doraprojects.net/blog/?p=1491" target="_blank" rel="noopener">Add connection in Netbeans 8 to the SQL Server 2012 database</a>.</li>
</ul>
<p>The post <a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/">How to connect Java to REST API (JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Calling Gmail REST API using SSIS &#8211; Read Emails</title>
		<link>https://zappysys.com/blog/calling-gmail-rest-api-using-ssis-read-emails/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Tue, 08 May 2018 19:26:59 +0000</pubDate>
				<category><![CDATA[REST API Integration]]></category>
		<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[SSIS PowerPack]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[rest]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=3359</guid>

					<description><![CDATA[<p>Introduction to get Gmail with REST API In this example, we will show how to read emails by calling Gmail REST API using SSIS. To illustrate, we will use ZappySys SSIS PowerPack, which includes several tasks to import/export data from multiples sources to multiple destinations like flat files, Azure, AWS, databases, Office files and more. [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/calling-gmail-rest-api-using-ssis-read-emails/">Calling Gmail REST API using SSIS &#8211; Read Emails</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction to get Gmail with REST API</h2>
<p>In this example, we will show how to <strong>read emails</strong> by <strong>calling Gmail REST API using SSIS</strong>. To illustrate, we will use <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a>, which includes several tasks to import/export data from multiples sources to multiple destinations like flat files, Azure, AWS, databases, Office files and more.</p>
<h2>Requirements</h2>
<ol>
<li>First, you will need <a href="https://zappysys.com/products/ssis-powerpack/download/">ZappySys SSIS PowerPack</a> installed.</li>
<li>Secondly, you will need SSDT installed.</li>
</ol>
<h2>Getting started</h2>
<h3>How to get information about Gmail with REST API</h3>
<ol>
<li>First, you will need to create a developer application for Gmail. The following tutorial shows how to create an application for Google Drive, but the steps are similar:
<ul>
<li><a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/">How to register Google OAuth Application (Get ClientID and ClientSecret)</a></li>
</ul>
</li>
<li>Secondly, go to SSDT and create a new SQL Server Integration Project.</li>
<li>Subsequently, drag and drop a Data Flow task and double-click it:
<div id="attachment_3369" style="width: 622px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/data-flow.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3369" class="size-full wp-image-3369" src="https://zappysys.com/blog/wp-content/uploads/2018/05/data-flow.png" alt="Using Data flow in SSIS" width="612" height="333" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/data-flow.png 612w, https://zappysys.com/blog/wp-content/uploads/2018/05/data-flow-300x163.png 300w" sizes="(max-width: 612px) 100vw, 612px" /></a><p id="caption-attachment-3369" class="wp-caption-text">Drag and drop Data Flow</p></div></li>
<li>Also, in the connection manager create a new ZS-OAuth connection. Select Google as the OAuth provider. In scopes, add the following:<br />
<pre class="crayon-plain-tag">https://mail.google.com/</pre>
In addition, press generate token and add your credentials if necessary:</p>
<div id="attachment_3382" style="width: 780px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/google-oauth-rest-api-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3382" class="size-full wp-image-3382" src="https://zappysys.com/blog/wp-content/uploads/2018/05/google-oauth-rest-api-1.png" alt="OAuth credentials" width="770" height="614" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/google-oauth-rest-api-1.png 770w, https://zappysys.com/blog/wp-content/uploads/2018/05/google-oauth-rest-api-1-300x239.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/google-oauth-rest-api-1-768x612.png 768w" sizes="(max-width: 770px) 100vw, 770px" /></a><p id="caption-attachment-3382" class="wp-caption-text">OAuth credentials to connect to Gmail</p></div>
<p>&nbsp;</li>
<li>To illustrate, the following example shows how to get the Gmail messages from an account. Check the option use credentials and select the OAuth connection just created. To get your current email messages, you can use the following URL:</p><pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/messages/</pre><p>
The filter used is the following:</p><pre class="crayon-plain-tag">$.messages[*].id</pre><p>
The result displayed shows the ids of the messages. You can see the id of the message in Gmail in the URL when you click a message:</p>
<div id="attachment_3373" style="width: 836px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/json-rest-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3373" class="size-full wp-image-3373" src="https://zappysys.com/blog/wp-content/uploads/2018/05/json-rest-api.png" alt="Get Gmail messages with REST API" width="826" height="733" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/json-rest-api.png 826w, https://zappysys.com/blog/wp-content/uploads/2018/05/json-rest-api-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/json-rest-api-768x682.png 768w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-3373" class="wp-caption-text">JSON Source Rest API</p></div>
<p>&nbsp;</li>
<li>If you want to check to information of a specific message you can use the following URL.</p><pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/messages/1632106341364d6f</pre><p>
Where 1632106341364d6f is the message id. The filter used will be the following:</p><pre class="crayon-plain-tag">$.id</pre><p>
<div id="attachment_3374" style="width: 665px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/snippet-info.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3374" class="size-full wp-image-3374" src="https://zappysys.com/blog/wp-content/uploads/2018/05/snippet-info.png" alt="Data extracted from Gmail" width="655" height="357" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/snippet-info.png 655w, https://zappysys.com/blog/wp-content/uploads/2018/05/snippet-info-300x164.png 300w" sizes="(max-width: 655px) 100vw, 655px" /></a><p id="caption-attachment-3374" class="wp-caption-text">Gmail message information</p></div>
<p>The query shows the snippet (body of the message), the history id, size estimated and more.</li>
<li>After this, we can use the following filter:</p><pre class="crayon-plain-tag">$.payload.headers[*]</pre><p>
This will show the sender, the receiver, subject, references, message ID and more information:</p>
<div id="attachment_3370" style="width: 516px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/date-information.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3370" class="size-full wp-image-3370" src="https://zappysys.com/blog/wp-content/uploads/2018/05/date-information.png" alt="To from IP information" width="506" height="356" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/date-information.png 506w, https://zappysys.com/blog/wp-content/uploads/2018/05/date-information-300x211.png 300w" sizes="(max-width: 506px) 100vw, 506px" /></a><p id="caption-attachment-3370" class="wp-caption-text">Information about Gmail</p></div></li>
</ol>
<h3>How to get label information in Gmail with REST API</h3>
<ol>
<li>First, you can use the following URL to get the Gmail labels:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/labels/</pre>
Filter:<br />
<pre class="crayon-plain-tag">$.labels[*].id</pre>
&nbsp;</li>
<li>Also, the information displayed is the following:
<div id="attachment_3375" style="width: 689px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-gmail.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3375" class="size-full wp-image-3375" src="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-gmail.png" alt="Gmail labels" width="679" height="557" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-gmail.png 679w, https://zappysys.com/blog/wp-content/uploads/2018/05/labes-gmail-300x246.png 300w" sizes="(max-width: 679px) 100vw, 679px" /></a><p id="caption-attachment-3375" class="wp-caption-text">Labels in Gmail</p></div></li>
<li>Finally, the labels are the same than in Gmail:
<div id="attachment_3376" style="width: 204px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-in-gmail-available.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3376" class="size-full wp-image-3376" src="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-in-gmail-available.png" alt="Gmail labels used" width="194" height="606" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/labes-in-gmail-available.png 194w, https://zappysys.com/blog/wp-content/uploads/2018/05/labes-in-gmail-available-96x300.png 96w" sizes="(max-width: 194px) 100vw, 194px" /></a><p id="caption-attachment-3376" class="wp-caption-text">Gmails labels, categories</p></div></li>
</ol>
<h3>How to get threads information in Gmail with REST API</h3>
<ol>
<li>Finally, you can also get the thread information using the following URL:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/threads</pre>
The filter used will be the following:<br />
<pre class="crayon-plain-tag">$.threads[*].id</pre>
&nbsp;</li>
<li>The information displayed will be the following:
<div id="attachment_3377" style="width: 836px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-thread.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3377" class="size-full wp-image-3377" src="https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-thread.png" alt="Threads in Gmail" width="826" height="733" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-thread.png 826w, https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-thread-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-thread-768x682.png 768w" sizes="(max-width: 826px) 100vw, 826px" /></a><p id="caption-attachment-3377" class="wp-caption-text">Get Threads from Gmail</p></div></li>
<li>If you press the Preview button, you will see the following information:
<div id="attachment_3378" style="width: 604px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/thread-information-gmail.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3378" class="size-full wp-image-3378" src="https://zappysys.com/blog/wp-content/uploads/2018/05/thread-information-gmail.png" alt="Gmail information with REST" width="594" height="357" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/thread-information-gmail.png 594w, https://zappysys.com/blog/wp-content/uploads/2018/05/thread-information-gmail-300x180.png 300w" sizes="(max-width: 594px) 100vw, 594px" /></a><p id="caption-attachment-3378" class="wp-caption-text">Thread information using Gmail</p></div></li>
</ol>
<h3>How to export the data from Gmail to a CSV file</h3>
<ol>
<li>First, to export the data, we will use the ZS Trash Destination:
<div id="attachment_3380" style="width: 303px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-to-a-csv-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3380" class="size-full wp-image-3380" src="https://zappysys.com/blog/wp-content/uploads/2018/05/gmail-to-a-csv-file.png" alt="Export data to a file" width="293" height="190" /></a><p id="caption-attachment-3380" class="wp-caption-text">Export data from Gmail to a CSV file</p></div></li>
<li>Finally, in the Trash Destination specify the path to store the data from Gmail:
<div id="attachment_3379" style="width: 646px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/csv-configuration-to-store-gmail-information.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3379" class="wp-image-3379 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/05/csv-configuration-to-store-gmail-information.png" alt="Gmail information stored to get Gmail with REST API" width="636" height="523" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/csv-configuration-to-store-gmail-information.png 636w, https://zappysys.com/blog/wp-content/uploads/2018/05/csv-configuration-to-store-gmail-information-300x247.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></a><p id="caption-attachment-3379" class="wp-caption-text">CSV destination to store Gmail info</p></div></li>
</ol>
<h2>Conclusion</h2>
<p>To conclude, we can say that <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a> is a powerful tool where you can get information from Gmail. This information can be exported to Excel, SQL Server, XML, JSON or any other format using SSIS.  <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">Download FREE Trial of SSIS PowerPack</a> to find out more use cases like this.</p>
<h2>References</h2>
<p>For more information about Gmail, you can refer to these links:</p>
<ul>
<li><a href="https://developers.google.com/gmail/api/v1/reference/">API Reference</a></li>
<li><a href="https://zappysys.com/blog/get-data-google-spreadsheet-using-ssis/">How to read / write Google SpreadSheet using SSIS</a></li>
</ul>
<p>The post <a href="https://zappysys.com/blog/calling-gmail-rest-api-using-ssis-read-emails/">Calling Gmail REST API using SSIS &#8211; Read Emails</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
