shippo-csharp-client
shippo-csharp-client copied to clipboard
Rate returns nothing when creating multi-pieces parcel
There is no rate return when creating multi-pieces parcel. Here is an example provided from its document.
APIResource resource = new APIResource(token);
Hashtable toAddressTable = new Hashtable();
toAddressTable.Add("name", "Mr. Hippo");
toAddressTable.Add("company", "Shippo");
toAddressTable.Add("street1", "215 Clayton St.");
toAddressTable.Add("city", "San Francisco");
toAddressTable.Add("state", "CA");
toAddressTable.Add("zip", "94117");
toAddressTable.Add("country", "US");
toAddressTable.Add("phone", "+1 555 341 9393");
toAddressTable.Add("email", "[email protected]");
Hashtable fromAddressTable = new Hashtable();
fromAddressTable.Add("name", "Ms Hippo");
fromAddressTable.Add("company", "San Diego Zoo");
fromAddressTable.Add("street1", "2920 Zoo Drive");
fromAddressTable.Add("city", "San Diego");
fromAddressTable.Add("state", "CA");
fromAddressTable.Add("zip", "92101");
fromAddressTable.Add("country", "US");
fromAddressTable.Add("email", "[email protected]");
fromAddressTable.Add("phone", "+1 619 231 1515");
fromAddressTable.Add("metadata", "Customer ID 123456");
List<Hashtable> parcelsList = new List<Hashtable>();
Hashtable parcelTable = new Hashtable();
parcelTable.Add("length", "5");
parcelTable.Add("width", "5");
parcelTable.Add("height", "5");
parcelTable.Add("distance_unit", "in");
parcelTable.Add("weight", "2");
parcelTable.Add("mass_unit", "lb");
Hashtable parcelTableTwo = new Hashtable();
parcelTableTwo.Add("length", "1");
parcelTableTwo.Add("width", "1");
parcelTableTwo.Add("height", "1");
parcelTableTwo.Add("distance_unit", "in");
parcelTableTwo.Add("weight", "2");
parcelTableTwo.Add("mass_unit", "lb");
parcelsList.Add(parcelTable);
parcelsList.Add(parcelTableTwo);
Hashtable shipmentTable = new Hashtable();
shipmentTable.Add("address_to", toAddressTable);
shipmentTable.Add("address_from", fromAddressTable);
shipmentTable.Add("parcels", parcelsList);
shipmentTable.Add("async", false);
Shipment shipment = resource.CreateShipment(shipmentTable);
Response.Write(shipment.Rates.Count().ToString()); // **output 0**
Same problem here...
pacotes.ForEach(x
=>
{
parcels.Add(new Hashtable() {
{ "length", x.Profundidade },
{ "width", x.Largura },
{ "height", x.Altura },
{ "distance_unit", "cm" },
{ "weight", x.Peso },
{ "mass_unit", "lb" },
});
});
`