Photo Gallery

Monday, September 25, 2017

UPS Rate API using C# ASP.NET Visual Studio 2013


In this post, we are going to see how to consume UPS RATE API using C#.

I am trying to learn Web Services and i am working on UPS online tool with ERP project and i can see that most of the people struggling to get response from API services. I created this post for those who wants to implement this API into their project/sites.

This post covers the step by step details to use Rate API into e-Commerce project. We will see the registration steps to get license key from UPS website and then will implement Rate API with example.

If you want some documents from UPS, click on this link UPSDeveloperKit.

Step - 1 Registration
Sign up for a UPS and you will get username and password if you don't have any.



Step - 2 Download API

Once you have username and password, log in with same and go to DeveloperAPI section and click on RATING API and download API called Rating.Zip.



Step - 3 Get Access Key
With the logged in page, request an access key, it will be displayed on browser or you will receive email with same key information.



Step - 4 Code Preparation
Extract the Zip folder and navigate to the WSDLs of Rate API service.

Folder Path reference : C:\PracticeProject\Rates_Pkg_Gnd\RatingPACKAGE\PACKAGEWebServices\SCHEMA-WSDLs



Step - 5 Go to Visual Studio
Create new project as Console Application



Step - 6 Add Web Reference
To add a web reference, follow the below steps.

Right click on project and click on Add - Service Reference



Click on Advance button



Click on Add Web Reference button



Provide full path of WSDL(Web Description Service Language) file and give proper name for web reference.

URL : ~\RatingPACKAGE\PACKAGEWebServices\SCHEMA-WSDLs\RateWS.wsdl

Web Reference Name : RateWebReference

Method : ProcessRate



Step - 7 Check App.config file
Please note how the visual studio adds properties binding configuration to app.config file.



Step - 8 Important
Make sure you have imported web reference to your Program.cs class



Step - 8 Code Modification
Add below code to Program.cs file

https://gist.github.com/chintaner/5773ed5c392d55b1ad575d8c113a2ee8.js

Step - 9 Execution
Execute the project with different input address.



Done.



If you have any questions, post here. Also, provide your valuable suggestions and thoughts in form of comments in the section below.

Thank you !!!


1 comment:

  1. Hello Chintan,Like to discuss UPS shipping API for console app in C#. you can email me your contact at santram@yahoo.comThank you,Rajan Desai

    ReplyDelete