Introduction
In our previous article we see How to read call REST API data in SSIS. Now in this article, we will see How to Make UPS API call in SSIS and load response into SQL Server. This blog mainly focuses on SSIS approach but steps mentioned to call UPS REST API Call can be useful for any developer regardless of which programming language or tool set you use. We will also see how to configure POST API Call.
We will go through the steps to make Pickup Creation Request API call which Returns a PRN and Rate Result and we load it into MS SQL Server.
In nutshell, this post will focus on how to Make UPS REST API Call in SSIS.
Prerequisites
Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
- SSIS designer installed. Sometimes it is referred to as BIDS or SSDT (download it from Microsoft site).
- Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
- Make sure ZappySys SSIS PowerPack is installed (download it).
- Credentials of UPS API.
What is UPS?
United Parcel Service Founded in 1907, UPS is the world’s largest package delivery company and a leading global provider of specialised transportation and logistics services. Using advanced technology, access to global resources, and an integrated network of physical, technological, and human assets, UPS provides a powerful competitive advantage that can help you earn repeat customers and grow your business.
Where to get the UPS Credentials?
You can get Username and password by signup in UPS website and also need to get Access Key from UPS Developer Kit.
Call UPS REST API using SSIS
Let’s start with an example. We use SSIS JSON Source component to make the call to UPS API, we will make Pickup Creation Request and load response into SQL Server. First of All, Open Visual Studio and Create New SSIS Package Project.
- First of All, Drag and drop Data Flow Task from SSIS Toolbox and double click it to edit.
- From the SSIS toolbox drag and drop JSON Source on the data flow designer surface.
- Double click JSON Source and enter the following URL as below to make Pickup Creation Request API Call and select Method as POST, I am using Testing URL but we need to use production one for real time API call.
Testing:
1https://wwwcie.ups.com/rest/Pickup
1https://onlinetools.ups.com/rest/Pickup - Furthermore, set below JSON string in the body and also replace your UPS username, password and access key in the placeholder, i used my dummy data you need to pass yours valid data.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647{"UPSSecurity": {"UsernameToken": {"Username": "[YOUR USERNAME]","Password": "[PASSWORD]"},"ServiceAccessToken": {"AccessLicenseNumber": "[ACCESS KEY]"}},"PickupCreationRequest": {"Request": {"TransactionReference": {"CustomerContext": "CustomerContext."}},"RatePickupIndicator": "Y","TaxInformationIndicator": "Y","PickupDateInfo": {"CloseTime": "1700","ReadyTime": "1000","PickupDate": "20191123"},"PickupAddress": {"CompanyName": "EIVR TEST NON-ACCOUNT PL 3","ContactName": "EIVR TES PL","AddressLine": "12380 Morris Rd","City": "Louisville","StateProvince": "KY","PostalCode": "40201","CountryCode": "US","ResidentialIndicator": "N","Phone": {"Number": "+48223803070"}},"AlternateAddressIndicator": "N","PickupPiece": {"ServiceCode": "003","Quantity": "1","DestinationCountryCode": "US","ContainerCode": "01"},"OverweightIndicator": "N","PaymentMethod": "05"}} - Now click on Select Filter button to get the desire filter.
- Finally click on Preview button to load the data.
- That’s it we are ready to load UPS Pickup Creation Request API call response in SQL Server.
Load UPS REST API data into SQL Server
- Inside Data Flow, Drag and drop Upsert Destination Component from SSIS Toolbox
- Connect our Source component to Upsert Destination
- Double click Upsert Destination to configure it
- Select Target Connection or click NEW to create new connection Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS
- Select Target Table or click NEW to create new table based on source columns
- Click on Mappings Tab to Auto map columns by name. You can change mappings as you need SSIS Upsert Destination - Columns Mappings
- Click OK to Save Upsert Destination Settings
- That's it, You are now ready to run data flow. NOTE: If you wish to debug data flow and see records when you run, add data viewer by right click on blue arrow > Click Enable Data Viewer
- To execute data flow, Right click anywhere inside Data Flow Surface and click Execute Task
Conclusion
After all, we saw you how to make UPS API call using SSIS JSON Source and load response into SQL Server. In this article we made Pickup Creation Request POST API call same way you can make other UPS API calls like Tracking API and Address Verification API and so on by passing relevant URL and JSON string. To explore many other scenarios not discussed in this article download SSIS PowerPack from here (includes 70+ Components).
References
Finally, you can use the following links for more information:
-
- Help File: JSON Source(REST API or File)
- UPS Developer Kit