Matt Schwartz
Matt Schwartz

Reputation: 3

DotNetShipping GetRates returns no results

I am trying to use the free DotNetShipping library to retrieve rates from FedEx. I've gotten all of the test credentials from FedEx, and I downloaded some sample code that I'm trying to get working. Here is my code:

       string fedexKey = "9nbqfLR71E4izdwj"; 
       string fedexPassword = "3SvlwGqXUstxdrCxSXMIgXzeK"; 
       string fedexAccountNumber = "510087720"; 
       string fedexMeterNumber = "259501201"; 

       // Setup package and destination/origin addresses
       var packages = new List<Package>();
       packages.Add(new Package(12, 12, 12, 35, 150)); // Length, Width, Height, Weight, Insured Value
       packages.Add(new Package(4, 4, 6, 15, 250)); // Length, Width, Height, Weight, Insured Value

       var origin = new DotNetShipping..Address("Chicago", "IL", "60601", "US"); // City, State, Postal Code, Country Code
       var destination = new DotNetShipping.Address("New York", "NY", "10001", "US"); // US Address

       // Create RateManager
       var rateManager = new RateManager();

       // Add desired DotNetShippingProviders
       rateManager.AddProvider(new FedExProvider(fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, false));

       // Call GetRates()
       Shipment shipment = rateManager.GetRates(origin, destination, packages);

       SqlCommand sqlCmd2 = new SqlCommand();
       DataTable table = new DataTable();
       table.Columns.Add("MyRate", typeof(string));
       foreach (Rate rate in shipment.Rates)
       {
           DataRow tableRow = table.NewRow();
           tableRow["MyRate"] = rate.ToString();
           table.Rows.Add(tableRow);
       }
       Repeater2.DataSource = table;
       Repeater2.DataBind();

I'm trying to bind the results to a repeater control, but no results come back - there are 0 rows in the result. I don't get an error either. I can't figure out how to get information back that will give me a clue as to what I am doing wrong. Any advice is greatly appreciated.

Upvotes: 0

Views: 32

Answers (0)

Related Questions