Reputation: 43
First time posting here, hope I'll ask my questions the right way :D
What I am doing I'm currently trying to integrate the UPS API's into an internal web application (using the Yii2-Framework) for my company. It's been quite the journey handling this documentation and finding (correct) information... UPS Shipping works fine, but I'm stuck with the Rating-API, when I try to rate a shipment in Shop-Option with TimeInTransit. I've been using JSON for all API's up until now.
What is wrong No matter what RequestOption or weight I try, it always responds with "Invalid Weight".
What I have tried As per the documentation, the string for the package weight must be exactly 6 characters long (odd, as that isn't the case for the Shipping API). With UnitOfMeasurement set to KGS, I tried every combination of 1, 10, 100 and 1000kg with Decimalpoints and -commas, both considering the Decimaldelimiter as a character and not,(even just having a 1, because that works fine when not including the TimeInTransit-Options) but the response is always the same. I tried googling the Error to see if somebody has had the same issue, or if find more information on this, but I haven't found anything usefull (or oversaw it). I've included my JSON below, did I do something wrong and don't see it?
JSON-Request
{
"RateRequest": {
"Request": {
"SubVersion": "v2205",
"RequestOption": "shoptimeintransit",
"TransactionReference": {
"CustomerContext": "TEST"
}
},
"Shipment": {
"Shipper": {
"Name": "[CompanyName",
"AttentionName": "[ContactName]",
"Phone": {
"Number": "[Number]"
},
"ShipperNumber": "[Number]",
"Address": {
"AddressLine": "[Some Address]",
"City": "[Some City]",
"PostalCode": "[Some ZIP]",
"CountryCode": "DE"
}
},
"ShipTo": {
"Name": "Mustermann GmbH",
"Address": {
"AddressLine": "Mustergasse 11",
"City": "Musterstadt",
"PostalCode": "123456",
"CountryCode": "DE"
}
},
"PaymentDetails": {
"ShipmentCharge": {
"Type": "01",
"BillShipper": {
"AccountNumber": "[Number]"
}
}
},
"Package": [
{
"PackagingType": {
"Code": "02"
},
"Dimensions": {
"UnitOfMeasurement": {
"Code": "CM",
"Description": "Centimeters"
},
"Length": "10",
"Width": "10",
"Height": "10"
},
"PackageWeight": {
"UnitOfMeasurement": {
"Code": "KGS",
"Description": "Kilograms"
},
"Weight": "10.000"
}
}
],
"DeliveryTimeInformation": {
"PackageBillType": "03"
}
}
}
}
Parameters
version: v2205
RequestOption: shoptimeintransit
transactionSrc: testing
Used in the "Try It"-Section on developer.ups.com
If some Info's missing, I'll happily abide, this has been a dreadful ride till now...
Upvotes: 4
Views: 1757
Reputation: 3799
According to the doc, if you are doing an international shipment, you need to add the ShipmentTotalWeight field under the Shipment field. However, seems like all oversea shipments even within US such as shipments to GU (Guam) needs this too. Might as well just always include this field.
{
"Shipment": {
"ShipmentTotalWeight": {
"UnitOfMeasurement": {
"Code": "KGS",
"Description": "Kilograms"
},
"Weight": "10"
}
}
}
According to the UPS document for this field:
Shipment Total Weight Container. This container is only applicable for "ratetimeintransit" and "shoptimeintransit" request options. Required for all international shipments when retreiving time in transit information, including letters and documents shipments.
Upvotes: 5
Reputation: 22960
I am shipping within Canada and using the "Shop" option and had the same error response and another similar error regarding dimensions. In my case the ShipmentTotalWeight
was not needed but what resolved it was to make sure the fields in question are in fact strings. I know this is not directly related to the OP's issue, but I wanted to add this answer here as I suspect this question may be a bit of a signpost for others.
In other words, this will not work:
"PackageWeight": {
"UnitOfMeasurement": {
"Code": "LBS",
"Description": "pounds"
},
"Weight": 10
}
But this will:
"PackageWeight": {
"UnitOfMeasurement": {
"Code": "LBS",
"Description": "pounds"
},
"Weight": "10"
}
In my application the request is being created in PHP so it was necessary to cast the weight as a string before converting to json.
Upvotes: 0