• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

UPS REST API Issue

New Here ,
May 20, 2024 May 20, 2024

Copy link to clipboard

Copied

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

Views

386

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2024 May 20, 2024

Copy link to clipboard

Copied

Sorry, this is the error message:

{"response":{"errors":[{"code":"110601","message":"Missing or invalid package weight for package 1."}]}}

and 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"
          },
          "PackageWeight": {
            "UnitOfMeasurement": {
              "Code": "LBS",
              "Description": "Pounds"
            },
            "Weight": "5"
          },
          "ShipmentTotalWeight": {
            "UnitOfMeasurement": {
              "Code": "LBS",
              "Description": "Pounds"
            },
            "Weight": "5"
          }	   
        }
      }
    }
  }>
	
<cfhttp url="https://wwwcie.ups.com/api/rating/v2403/shop" method="post" result="hello3">
	<cfhttpparam type="header" name="Content-Type" value="application/json" />
	<cfhttpparam type="header" name="transId" value="string" />
	<cfhttpparam type="header" name="transactionSrc" value="testing" />
	<cfhttpparam type="header" name="Authorization" value="Bearer #ups_access_token#" />
    <cfhttpparam type="body" value="#serializeJSON(obj)#">	
</cfhttp>

<cfdump var="#hello3#" />
	

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2024 May 27, 2024

Copy link to clipboard

Copied

Did you find a solution? If you look at the UPS docs, I believe the package should be an array:

https://developer.ups.com/api/reference?loc=en_US#operation/Rate!path=RateRequest/Shipment/Package&t...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2024 Jun 01, 2024

Copy link to clipboard

Copied

LATEST

I don't think you need anyone's help. This is a problem you can solve yourself, as the API has returned a clear error message, namely:

"All package dimensions are required and each must be greater than 0 for package 1."

Check the documentation, and make sure your JSON contains all the required attributes for package.

I also noticed that you use 

PackageWeight2

for the attribute instead of

PackageWeight

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation