如何修复 USPS "The element has invalid child element" API 错误?

How to fix USPS "The element has invalid child element" API error?

我正在尝试使用 USPS API 来计算运费。这是我发送给 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>

这就是我得到的: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 说: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..

我不知道我做错了什么。有人可以帮我吗?

我找到问题所在了。我不得不把 Width 放在第一位,然后放在 LengthHeightGirth 之前。所以这是一个有效的请求:

<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>