May 21, 2024
UPS API ISSUE
Comments
(1)
May 21, 2024
UPS API ISSUE
Newbie 1 posts
Followers: 0 people
(1)

Hello,

I am working on integrating UPS REST API and getting error message:

{"response":{"errors":[{"code":"110609","message":"All package dimensions are required and each must be greater than 0 for package 1."}]}}

This is my code:

<!--- Get UPS Access Token Information --->
<cfhttp url="https://wwwcie.ups.com/security/v1/oauth/token" method="post" result="ups_authorization">
	<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
	<cfhttpparam type="header" name="x-merchant-id" value="#UPSAccountNumber#" />
	<cfhttpparam type="header" name="Authorization" value="Basic #ToBase64(clientID & ':' & secretKey)#" />
	<cfhttpparam name="grant_type" value="client_credentials" type="formfield">	
</cfhttp>
	
<cfset ups_access_token_json = DeserializeJSON(ToString(ups_authorization.filecontent))	/>
<cfset ups_access_token	= ups_access_token_json.access_token />

<!--- Get UPS Shipping Rates --->
<cfset obj ={
    "RateRequest": {
      "Request": {
        "TransactionReference": {
          "CustomerContext": "CustomerContext"
        }
      },
      "Shipment": {
        "Shipper": {
          "Name": "ShipperName",
          "ShipperNumber": "123456",
          "Address": {
            "AddressLine": [
              "ShipperAddressLine",
              "ShipperAddressLine",
              "ShipperAddressLine"
            ],
            "City": "TIMONIUM",
            "StateProvinceCode": "MD",
            "PostalCode": "21093",
            "CountryCode": "US"
          }
        },
        "ShipTo": {
          "Name": "ShipToName",
          "Address": {
            "AddressLine": [
              "ShipToAddressLine",
              "ShipToAddressLine",
              "ShipToAddressLine"
            ],
            "City": "Alpharetta",
            "StateProvinceCode": "GA",
            "PostalCode": "30005",
            "CountryCode": "US"
          }
        },
        "ShipFrom": {
          "Name": "ShipFromName",
          "Address": {
            "AddressLine": [
              "ShipFromAddressLine",
              "ShipFromAddressLine",
              "ShipFromAddressLine"
            ],
            "City": "TIMONIUM",
            "StateProvinceCode": "MD",
            "PostalCode": "21093",
            "CountryCode": "US"
          }
        },
        "PaymentDetails": {
          "ShipmentCharge": {
            "Type": "01",
            "BillShipper": {
              "AccountNumber": "123456"
            }
          }
        },
        "Service": {
          "Code": "03",
          "Description": "Ground"
        },
        "NumOfPieces": "1",
        "Package": {
          "SimpleRate": {
            "Description": "SimpleRateDescription",
            "Code": "XS"
          },
          "PackagingType": {
            "Code": "02",
            "Description": "Packaging"
          },
          "Dimensions": {
            "UnitOfMeasurement": {
              "Code": "IN",
              "Description": "Inches"
            },
            "Length": "5",
            "Width": "5",
            "Height": "5"
          },
          "PackageWeight2": {
            "UnitOfMeasurement": {
              "Code": "LBS",
              "Description": "Pounds"
            },
            "Weight": "1.5"
          },
          "ShipmentTotalWeight": {
            "UnitOfMeasurement": {
              "Code": "LBS",
              "Description": "Pounds"
            },
            "Weight": "1.5"
          }	   
        }
      }
    }
  }>

As you can see I am sending the weight to UPS but for some reason it is not reading it, any suggestions as to why not?

This is UPS API documentation: https://developer.ups.com/api/reference?loc=en_US#operation/Rate

1 Comment
2024-06-03 14:10:22
2024-06-03 14:10:22

You may need to reach out to the UPS folks for a better answer on using their service, but — the api documentation states that dimensions are to be text strings — 6 digits in length with 2 digits of significance after the decimal point.

I’d try passing each dimension in as 5.0000 and see what happens.  I know their code examples show use of the integer format, but that’s what I stumbled across on another forum.

Like
Add Comment