I'm trying to use USPS API to calculate shipping charge. Here's the request I'm sending to https://secure.shippingapis.com/ShippingAPI.dll
:
<?xml version="1.0" encoding="UTF-8"?>
<RateV4Request USERID="XXXXXXXXXXXX">
<Package ID="1">
<Service>PARCEL SELECT GROUND</Service>
<ZipOrigination>34249</ZipOrigination>
<ZipDestination>97220</ZipDestination>
<Pounds>5.8</Pounds>
<Ounces>0</Ounces>
<Container>VARIABLE</Container>
<Length>7</Length>
<Width>7</Width>
<Height>7</Height>
<Girth>28</Girth>
</Package>
</RateV4Request>
And this is what I get: The element 'Package' has invalid child element 'Width'. List of possible elements expected: 'Value, AmountToCollect, SpecialServices, Content, GroundOnly, SortBy, Machinable, ReturnLocations, ReturnServiceInfo, DropOffTime, ShipDate, RatePriceType, RatePaymentType, SortationLevel, DestinationEntryFacilityType, Nonprofit, ReturnDimensionalWeight, TrackingRetentionPeriod'.
.
Documentation says: Value must be numeric. Units are inches. If partial dimensions are provided, an error response will return. Length, Width, Height are required for accurate pricing of a rectangular package when any dimension of the item exceeds 12 inches. In addition, Girth is required only for a nonrectangular package in addition to Length, Width, Height when any dimension of the package exceeds 12 inches. For rectangular packages, the Girth dimension must be left blank as this dimension is to only be used for nonrectangular packages.
.
I have no idea what I'm doing wrong. Can anybody help me out?
I found where the problem was. I had to put Width
first, before Length
, Height
and Girth
. So this is a valid request:
<Package ID="1">
<Service>PARCEL SELECT GROUND</Service>
<ZipOrigination>34249</ZipOrigination>
<ZipDestination>97220</ZipDestination>
<Pounds>5.8</Pounds>
<Ounces>0</Ounces>
<Container>VARIABLE</Container>
<Width>7</Width>
<Length>7</Length>
<Height>7</Height>
<Girth>28</Girth>
</Package>