<?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>PHP Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/category/odbc-powerpack/odbc-programming/programming-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/category/odbc-powerpack/odbc-programming/programming-php/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 24 Aug 2023 21:53:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>PHP Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/category/odbc-powerpack/odbc-programming/programming-php/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to call REST API in Python (Read JSON / SOAP XML)</title>
		<link>https://zappysys.com/blog/set-rest-python-client/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Wed, 11 Apr 2018 19:46:41 +0000</pubDate>
				<category><![CDATA[JSON File / REST API Driver]]></category>
		<category><![CDATA[ODBC PowerPack]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[XML File / SOAP API Driver]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=3184</guid>

					<description><![CDATA[<p>Introduction to REST API Call in Python In this article, we will cover how to call REST API in Python without using REST Python client. We will use ZappySys ODBC Driver for JSON / REST API. This driver allows querying RESTful API Services without extensive coding effort. For demo purpose, we will see examples to call [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/set-rest-python-client/">How to call REST API in Python (Read JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction to REST API Call in Python</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/python-logo.png"><img decoding="async" class="alignleft wp-image-3195 " src="https://zappysys.com/blog/wp-content/uploads/2018/04/python-logo.png" alt="The logo of Python" width="119" height="119" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/python-logo.png 200w, https://zappysys.com/blog/wp-content/uploads/2018/04/python-logo-150x150.png 150w" sizes="(max-width: 119px) 100vw, 119px" /></a></p>
<p>In this article, we will cover how to call REST API in Python without using REST Python client. We will use <a href="https://zappysys.com/products/odbc-powerpack/" target="_blank" rel="noopener">ZappySys ODBC Driver for JSON / REST API</a>. This driver allows querying RESTful API Services without extensive coding effort. For demo purpose, we will see examples to call JSON based REST API in Python. However, the same concept can be used to connect to an XML file, JSON file, REST API, SOAP, Web API.</p>
<p>In this example, we will connect to the following JSON Service URL and query using Python Script.</p><pre class="crayon-plain-tag">https://services.odata.org/V3/Northwind/Northwind.svc/?$format=json</pre><p>
&nbsp;</p>
<h2>Requirements</h2>
<ol>
<li>First, make sure to install Python (we used the 3.6 version)</li>
<li>Secondly, make sure that the <a href="https://zappysys.com/products/odbc-powerpack/">ZappySys ODBC PowerPack </a>is installed</li>
</ol>
<h2>Getting started</h2>
<h3>Install pip</h3>
<p>If not installed before, you will need to install pip. Pip is a package management system created in Python. To install it, go here for more information:</p>
<p>Next, install Pip using the following instructions: <a href="https://pip.pypa.io/en/stable/installing/">https://pip.pypa.io/en/stable/installing/</a></p>
<h3>Install pyodbc</h3>
<p>After installing Pip, you will need to install pyodbc. Pyodbc will connect to an ODBC driver. To install pyodbc go to your python scripts on your machine:</p>
<pre class="crayon-plain-tag">C:\PythonXX\Scripts&gt;</pre>
<p>Where <strong>XX</strong> is the current version</p>
<p>Also, in the script folder run the following command:<br />
pip install pyodbc<br />
This will install the pyodbc to connect to an ODBC driver.</p>
<h3>Code example to get JSON information in Python</h3>
<p>We will create a python script named zappyodbc.py in the script folder with the following code:</p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect(
    r'DRIVER={ZappySys JSON Driver};'
    )
cursor = conn.cursor()	
 
#execute query to fetch data from API service
cursor.execute("SELECT * FROM value ORDER BY Country WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')") 
row = cursor.fetchone() 
while row: 
    print (row) 
    row = cursor.fetchone()</pre><p>
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">Python is sensitive to indents. You may have problems with a copy-paste of the code. If that is your case, try the file below and change the extension from txt to py.</div></div>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-sample.txt">Download odbc sample</a></p>
<div id="attachment_10230" style="width: 1139px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-10230" class="size-full wp-image-10230" src="https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult.png" alt="" width="1129" height="514" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult.png 1129w, https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult-300x137.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult-768x350.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/04/pythonResult-1024x466.png 1024w" sizes="(max-width: 1129px) 100vw, 1129px" /></a><p id="caption-attachment-10230" class="wp-caption-text">CMD result</p></div>
<p>Also, the code will return the first row of the following URL with data in JSON format if you use row[0]:</p>
<div id="attachment_3189" style="width: 927px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-to-json-example.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3189" class="wp-image-3189 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-to-json-example.jpg" alt="Python reading JSON as REST Python client " width="917" height="448" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-to-json-example.jpg 917w, https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-to-json-example-300x147.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-to-json-example-768x375.jpg 768w" sizes="(max-width: 917px) 100vw, 917px" /></a><p id="caption-attachment-3189" class="wp-caption-text">Python results querying REST API</p></div>
<h3>Get values from REST API and JSON with a where clause</h3>
<p>The next example will show how to display 2 rows using filters. We will show the customer id and the company name of the customers from Germany:</p>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc-sample.txt">Download </a><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/odbc_where.txt">odbc_where file.</a></p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect(
    r'DRIVER={ZappySys JSON Driver};'
    )
cursor = conn.cursor()	
 
#execute query to fetch data from API service
cursor.execute("SELECT CustomerID,CompanyName FROM value WHERE COUNTRY='Germany' WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json')") 
row = cursor.fetchone() 
while row: 
    print (row[0]) 
    row = cursor.fetchone()</pre><p>
<h3>How to get values in Python from a local file</h3>
<p>First, we will add the following  JSON file named customer1.json:</p><pre class="crayon-plain-tag">{
  "value": [
    {
      "CustomerID": "ALFKI",
      "CompanyName": "Alfreds Futterkiste",
      "ContactName": "Maria Anders",
      "ContactTitle": "Sales Representative",
      "Address": "Obere Str. 57",
      "City": "Berlin",
      "Region": null,
      "PostalCode": "12209",
      "Country": "Germany",
      "Phone": "030-0074321",
      "Fax": "030-0076545"
    },
    {
      "CustomerID": "ANATR",
      "CompanyName": "Ana Trujillo Emparedados y helados",
      "ContactName": "Ana Trujillo",
      "ContactTitle": "Owner",
      "Address": "Avda. de la Constitución 2222",
      "City": "México D.F.",
      "Region": null,
      "PostalCode": "05021",
      "Country": "Mexico",
      "Phone": "(5) 555-4729",
      "Fax": "(5) 555-3745"
    },
    {
      "CustomerID": "ANTON",
      "CompanyName": "Antonio Moreno Taquería",
      "ContactName": "Antonio Moreno",
      "ContactTitle": "Owner",
      "Address": "Mataderos 2312",
      "City": "México D.F.",
      "Region": null,
      "PostalCode": "05023",
      "Country": "Mexico",
      "Phone": "(5) 555-3932",
      "Fax": null
    },
    {
      "CustomerID": "AROUT",
      "CompanyName": "Around the Horn",
      "ContactName": "Thomas Hardy",
      "ContactTitle": "Sales Representative",
      "Address": "120 Hanover Sq.",
      "City": "London",
      "Region": null,
      "PostalCode": "WA1 1DP",
      "Country": "UK",
      "Phone": "(171) 555-7788",
      "Fax": "(171) 555-6750"
    },
    {
      "CustomerID": "BERGS",
      "CompanyName": "Berglunds snabbköp",
      "ContactName": "Christina Berglund",
      "ContactTitle": "Order Administrator",
      "Address": "Berguvsvägen 8",
      "City": "Luleå",
      "Region": null,
      "PostalCode": "S-958 22",
      "Country": "Sweden",
      "Phone": "0921-12 34 65",
      "Fax": "0921-12 34 67"
    },
    {
      "CustomerID": "BLAUS",
      "CompanyName": "Blauer See Delikatessen",
      "ContactName": "Hanna Moos",
      "ContactTitle": "Sales Representative",
      "Address": "Forsterstr. 57",
      "City": "Mannheim",
      "Region": null,
      "PostalCode": "68306",
      "Country": "Germany",
      "Phone": "0621-08460",
      "Fax": "0621-08924"
    },
    {
      "CustomerID": "BLONP",
      "CompanyName": "Blondesddsl père et fils",
      "ContactName": "Frédérique Citeaux",
      "ContactTitle": "Marketing Manager",
      "Address": "24, place Kléber",
      "City": "Strasbourg",
      "Region": null,
      "PostalCode": "67000",
      "Country": "France",
      "Phone": "88.60.15.31",
      "Fax": "88.60.15.32"
    },
    {
      "CustomerID": "BOLID",
      "CompanyName": "Bólido Comidas preparadas",
      "ContactName": "Martín Sommer",
      "ContactTitle": "Owner",
      "Address": "C/ Araquil, 67",
      "City": "Madrid",
      "Region": null,
      "PostalCode": "28023",
      "Country": "Spain",
      "Phone": "(91) 555 22 82",
      "Fax": "(91) 555 91 99"
    },
    {
      "CustomerID": "BONAP",
      "CompanyName": "Bon app'",
      "ContactName": "Laurence Lebihan",
      "ContactTitle": "Owner",
      "Address": "12, rue des Bouchers",
      "City": "Marseille",
      "Region": null,
      "PostalCode": "13008",
      "Country": "France",
      "Phone": "91.24.45.40",
      "Fax": "91.24.45.41"
    },
    {
      "CustomerID": "BOTTM",
      "CompanyName": "Bottom-Dollar Markets",
      "ContactName": "Elizabeth Lincoln",
      "ContactTitle": "Accounting Manager",
      "Address": "23 Tsawassen Blvd.",
      "City": "Tsawassen",
      "Region": "BC",
      "PostalCode": "T2F 8M4",
      "Country": "Canada",
      "Phone": "(604) 555-4729",
      "Fax": "(604) 555-3745"
    },
    {
      "CustomerID": "BSBEV",
      "CompanyName": "B's Beverages",
      "ContactName": "Victoria Ashworth",
      "ContactTitle": "Sales Representative",
      "Address": "Fauntleroy Circus",
      "City": "London",
      "Region": null,
      "PostalCode": "EC2 5NT",
      "Country": "UK",
      "Phone": "(171) 555-1212",
      "Fax": null
    },
    {
      "CustomerID": "CACTU",
      "CompanyName": "Cactus Comidas para llevar",
      "ContactName": "Patricio Simpson",
      "ContactTitle": "Sales Agent",
      "Address": "Cerrito 333",
      "City": "Buenos Aires",
      "Region": null,
      "PostalCode": "1010",
      "Country": "Argentina",
      "Phone": "(1) 135-5555",
      "Fax": "(1) 135-4892"
    },
    {
      "CustomerID": "CENTC",
      "CompanyName": "Centro comercial Moctezuma",
      "ContactName": "Francisco Chang",
      "ContactTitle": "Marketing Manager",
      "Address": "Sierras de Granada 9993",
      "City": "México D.F.",
      "Region": null,
      "PostalCode": "05022",
      "Country": "Mexico",
      "Phone": "(5) 555-3392",
      "Fax": "(5) 555-7293"
    },
    {
      "CustomerID": "CHOPS",
      "CompanyName": "Chop-suey Chinese",
      "ContactName": "Yang Wang",
      "ContactTitle": "Owner",
      "Address": "Hauptstr. 29",
      "City": "Bern",
      "Region": null,
      "PostalCode": "3012",
      "Country": "Switzerland",
      "Phone": "0452-076545",
      "Fax": null
    },
    {
      "CustomerID": "COMMI",
      "CompanyName": "Comércio Mineiro",
      "ContactName": "Pedro Afonso",
      "ContactTitle": "Sales Associate",
      "Address": "Av. dos Lusíadas, 23",
      "City": "Sao Paulo",
      "Region": "SP",
      "PostalCode": "05432-043",
      "Country": "Brazil",
      "Phone": "(11) 555-7647",
      "Fax": null
    },
    {
      "CustomerID": "CONSH",
      "CompanyName": "Consolidated Holdings",
      "ContactName": "Elizabeth Brown",
      "ContactTitle": "Sales Representative",
      "Address": "Berkeley Gardens 12 Brewery",
      "City": "London",
      "Region": null,
      "PostalCode": "WX1 6LT",
      "Country": "UK",
      "Phone": "(171) 555-2282",
      "Fax": "(171) 555-9199"
    },
    {
      "CustomerID": "DRACD",
      "CompanyName": "Drachenblut Delikatessen",
      "ContactName": "Sven Ottlieb",
      "ContactTitle": "Order Administrator",
      "Address": "Walserweg 21",
      "City": "Aachen",
      "Region": null,
      "PostalCode": "52066",
      "Country": "Germany",
      "Phone": "0241-039123",
      "Fax": "0241-059428"
    },
    {
      "CustomerID": "DUMON",
      "CompanyName": "Du monde entier",
      "ContactName": "Janine Labrune",
      "ContactTitle": "Owner",
      "Address": "67, rue des Cinquante Otages",
      "City": "Nantes",
      "Region": null,
      "PostalCode": "44000",
      "Country": "France",
      "Phone": "40.67.88.88",
      "Fax": "40.67.89.89"
    },
    {
      "CustomerID": "EASTC",
      "CompanyName": "Eastern Connection",
      "ContactName": "Ann Devon",
      "ContactTitle": "Sales Agent",
      "Address": "35 King George",
      "City": "London",
      "Region": null,
      "PostalCode": "WX3 6FW",
      "Country": "UK",
      "Phone": "(171) 555-0297",
      "Fax": "(171) 555-3373"
    },
    {
      "CustomerID": "ERNSH",
      "CompanyName": "Ernst Handel",
      "ContactName": "Roland Mendel",
      "ContactTitle": "Sales Manager",
      "Address": "Kirchgasse 6",
      "City": "Graz",
      "Region": null,
      "PostalCode": "8010",
      "Country": "Austria",
      "Phone": "7675-3425",
      "Fax": "7675-3426"
    }
  ]
}</pre><p>
Next, use the following Python code shows how to get values from a file named customer1.json:</p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect(
    r'DRIVER={ZappySys JSON Driver};'
    )
cursor = conn.cursor()	
 
#execute query to fetch data from API service
cursor.execute("SELECT CustomerID,ContactName FROM value WITH (SRC=@'C:\sql\customer2.json')") 

row = cursor.fetchone() 
while row: 
#print two rows
    print (row[0],row[1]) 
    row = cursor.fetchone()</pre><p>
<h3>How to read data from multiple JSON files in Python</h3>
<p>Also, the following example with extract data from multiple JSON files with names that start with cust. For example customer1.json, customer2.json, etc:</p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect(
r'DRIVER={ZappySys JSON Driver};'
)
cursor = conn.cursor() 

#execute query to fetch data from API service
cursor.execute("SELECT CustomerID,ContactName FROM value WITH (SRC=@'C:/sql/cust*.json')")

row = cursor.fetchone() 
while row: 
#print two rows
  print (row[0],row[1]) 
  row = cursor.fetchone()</pre><p>
<h3>How to store your data from REST API or JSON to a CSV file in Python</h3>
<p>Finally, the next example will show how to store your values from a JSON file or a REST API call to a local CSV file named customer.csv:</p>
<div>
<div>
<pre class="crayon-plain-tag">import csv
import pyodbc

conn = pyodbc.connect(
r'DRIVER={ZappySys JSON Driver};'
)
cursor = conn.cursor()
rows = cursor.execute("SELECT CustomerID,CompanyName FROM value WHERE COUNTRY='Germany' WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json')")
with open(r'C:/sql/customer.csv', 'w', newline='') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow([x[0] for x in cursor.description])
    for row in rows:
        writer.writerow(row)</pre>
</div>
</div>
<h3>How to connect using OAuth in Python to connect to Google Sheet</h3>
<p>Oauth is a standard to connect to Web applications or services. In this example, we will get the rows from a google sheet:</p>
<p>We will use our ZappySys ODBC PowerPack Driver. In Windows ODBC Data Sources, add the ZappySys  JSON Driver.</p>
<p>Add an URL like the following in Data Source:</p><pre class="crayon-plain-tag">https://sheets.googleapis.com/v4/spreadsheets/{spreadSheet_id}/values/'{table_name}'!A2:F</pre><p>
In addition, go to Authentication type and select OAuth and in OAuth settings, press the button. The Data source name in this example is ZappySys Google Sheet:</p>
<p>Also, in settings go to OAuth Provider and select Gogle Sheet + Drive. The Client Id and Client Secret are provided by an application created in the Google Console, <a href="https://zappysys.com/blog/register-google-oauth-application-get-clientid-clientsecret/" target="_blank" rel="noopener">Check this article</a> for step-by-step instructions.</p>
<p>In scopes we will use https://www.googleapis.com/auth/spreadsheets and https://www.googleapis.com/auth/spreadsheets.readonly then press Generate Token:</p>
<div id="attachment_10224" style="width: 868px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10224" class="size-full wp-image-10224" src="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet1.png" alt="" width="858" height="776" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet1.png 858w, https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet1-300x271.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet1-768x695.png 768w" sizes="(max-width: 858px) 100vw, 858px" /></a><p id="caption-attachment-10224" class="wp-caption-text">Google Sheet OAuth connection</p></div>
<p>Finally, this is the code used to get the rows from a spreadsheet in Python:</p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect('DSN=Google Sheet example')

cursor = conn.cursor() 

#execute query to fetch data from API service
cursor.execute("SELECT * FROM $") 
row = cursor.fetchone() 
while row: 
    print (row[1]) 
    row = cursor.fetchone()</pre><p>
Finally, the rows are displayed:</p>
<div id="attachment_10225" style="width: 1036px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10225" class="size-full wp-image-10225" src="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2.png" alt="" width="1026" height="343" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2.png 1026w, https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2-300x100.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2-768x257.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/04/googlesheet2-1024x342.png 1024w" sizes="(max-width: 1026px) 100vw, 1026px" /></a><p id="caption-attachment-10225" class="wp-caption-text">The result, rows from the spreadsheet</p></div>
<p>&nbsp;</p>
<h3>How to read Gmail information in Python</h3>
<p>To start this new example, we will show how to get Gmail information in Python.</p>
<p>After that, we will add an ODBC DSN to connect to Gmail as we did with Google Sheet. Next, we will select OAuth to connect to Google. In Data Source, we will use a URL similar to this one:</p><pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/{user-id}/messages/{message-id}</pre><p>
Where user-id is your email account. For example zappysys@gmail.com or you can use &#8220;me&#8221;. The message id can be obtained when you click on your gmail message in a browser:</p>
<div id="attachment_3282" style="width: 862px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/google-message-id.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3282" class="size-full wp-image-3282" src="https://zappysys.com/blog/wp-content/uploads/2018/04/google-message-id.png" alt="message id" width="852" height="175" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/google-message-id.png 852w, https://zappysys.com/blog/wp-content/uploads/2018/04/google-message-id-300x62.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/google-message-id-768x158.png 768w" sizes="(max-width: 852px) 100vw, 852px" /></a><p id="caption-attachment-3282" class="wp-caption-text">Gmail message id</p></div>
<p>Also, your configuration should be similar to this one. Press the OAuth Settings button, in your OAuth parameters in OAuth Provider, select Google, in scopes, write https://mail.google.com/ and finally press Generate Token:</p>
<div id="attachment_10226" style="width: 932px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10226" class="size-full wp-image-10226" src="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail1.png" alt="" width="922" height="729" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail1.png 922w, https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail1-300x237.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail1-768x607.png 768w" sizes="(max-width: 922px) 100vw, 922px" /></a><p id="caption-attachment-10226" class="wp-caption-text">Gmail OAuth configuration</p></div>
<p>After that, your configuration is ready, use the following code to get data:</p><pre class="crayon-plain-tag">import pyodbc

conn = pyodbc.connect('DSN=Google Gmail example')

cursor = conn.cursor() 

#execute query to fetch data from API service
cursor.execute("select name,value from [payload.headers]") 
row = cursor.fetchone()

while row: 
   print ("name:"+row[0]+" value:"+row[1]) 
   row = cursor.fetchone()</pre><p>
Finally, the query will show the sender of the email message, the receiver, IP information of the sender (if provided):</p>
<div id="attachment_10227" style="width: 1139px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10227" class="size-full wp-image-10227" src="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2.png" alt="" width="1129" height="514" srcset="https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2.png 1129w, https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2-300x137.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2-768x350.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/04/googleGmail2-1024x466.png 1024w" sizes="(max-width: 1129px) 100vw, 1129px" /></a><p id="caption-attachment-10227" class="wp-caption-text">Result from the Message</p></div>
<h2>Calling XML SOAP Web Service in Python</h2>
<p>So far we have looked at examples to consume data using JSON driver. Now let&#8217;s look at an example, to call XML SOAP Web Service in Python.</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>SOAP / REST API pagination in Python</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>SOAP / REST API Error Handling in Python</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>Security / Connection Types (Options for HTTP, OAuth, SOAP) in Python</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>
<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>Conclusion</h2>
<p>In conclusion, we can say that working to get a REST Python client. We learn how to get information from a JSON file or REST using the <a href="https://zappysys.com/products/odbc-powerpack/">ZappySys ODBC PowerPack</a>.</p>
<h2>References</h2>
<p>Finally, you can use the following links for more information:</p>
<ul>
<li><a href="https://pip.pypa.io/en/stable/installing/">Python Pip installation.</a></li>
<li><a href="https://www.progress.com/blogs/tutorial-connecting-to-odbc-data-sources-with-python-and-pyodbc">Work with ODBC in Python </a></li>
<li><a href="https://docs.python.org/2/library/csv.html">Work with CSV in Python</a></li>
</ul>
<p><strong>Keywords:</strong></p>
<p>REST Python client example, REST Python client JSON, REST Python client library, REST Python API</p>
<p>The post <a href="https://zappysys.com/blog/set-rest-python-client/">How to call REST API in Python (Read JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
