2

我在加拿大和美国国家/地区使用 UPS API,发货地始终是加拿大。以下是我传递的请求,以获取 UPS 费率并获取预计到达时间。如果我为加拿大地址传递以下请求参数,它可以正常响应,但如果我在 UPS API 请求参数中传递美国地址,则会引发Invalid Shipment Contents Value错误。

以下是适用于加拿大地址的 UPS API请求及其响应,但不适用于任何美国地址:

要求

<AccessRequest xml:lang="en-US">    
  <AccessLicenseNumber>******</AccessLicenseNumber> 
  <UserId>*****</UserId>    
  <Password>*****</Password>    
</AccessRequest><?xml version="1.0"?>   
<RatingServiceSelectionRequest xml:lang="en-US">    
  <Request> 
    <TransactionReference>  
      <CustomerContext>Rating and Service</CustomerContext> 
      <XpciVersion>1.0</XpciVersion>    
    </TransactionReference> 
    <RequestAction>Rate</RequestAction> 
    <RequestOption>Shoptimeintransit</RequestOption>    
  </Request>    
  <PickupType>  
          <Code>01</Code>   
          <Description>Regular Daily Pickup</Description>   
  </PickupType> 
  <Shipment>      <Shipper><ShipperNumber>****</ShipperNumber>      <Address>   
          <City>Scarborough</City>  
          <PostalCode>M1G 0A6</PostalCode>  
          <CountryCode>CA</CountryCode> 
          <StateProvinceCode>ON</StateProvinceCode> 
      </Address>    
    </Shipper>  
    <ShipTo>    
      <Address> 
          <PostalCode>14304</PostalCode>    
          <CountryCode>US</CountryCode> 
          <ResidentialAddress>02</ResidentialAddress>   
          <StateProvinceCode>NY</StateProvinceCode>      </Address> 
    </ShipTo>   
    <ShipFrom>  
      <Address> 
          <PostalCode>M1G 0A6</PostalCode>  
          <CountryCode>CA</CountryCode> 
          <StateProvinceCode>ON</StateProvinceCode> 
      </Address>    
    </ShipFrom> 
    <DeliveryTimeInformation>   
    <PackageBillType>03</PackageBillType>   
</DeliveryTimeInformation>  
    <Package>   
      <PackagingType>   
        <Code>00</Code> 
      </PackagingType>  
      <PackageWeight>   
        <UnitOfMeasurement> 
          <Code>LBS</Code>  
        </UnitOfMeasurement>    
        <Weight>0.2</Weight>    
      </PackageWeight>  
    </Package>  
    <ShipmentTotalWeight>   
    <UnitOfMeasurement> 
        <Code>LBS</Code>    
    </UnitOfMeasurement>    
    <Weight>0.2</Weight>    
    </ShipmentTotalWeight><RateInformation><NegotiatedRatesIndicator/></RateInformation>      </Shipment>   
    </RatingServiceSelectionRequest>

回复

<RatingServiceSelectionResponse>
    <Response>
        <TransactionReference>
            <CustomerContext>Rating and Service</CustomerContext>
            <XpciVersion>1.0</XpciVersion>
        </TransactionReference>
        <ResponseStatusCode>0</ResponseStatusCode>
        <ResponseStatusDescription>Failure</ResponseStatusDescription>
        <Error>
            <ErrorSeverity>Hard</ErrorSeverity>
            <ErrorCode>111549</ErrorCode>
            <ErrorDescription>Invalid Shipment Contents Value.</ErrorDescription>
        </Error>
    </Response>
</RatingServiceSelectionResponse>

我在上面的美国地址请求中做错了什么?

4

2 回答 2

1

使用此 API 时似乎经常出现错误。我做了一些谷歌搜索,这些是我找到的信息的一些链接。

https://twitter.com/shippo/status/952965049840054272

https://www.ups.com/lk/en/help-center/sri/apishippingerror.page

还有这个指南,也许它可能有用。

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwiiy_u244v1AhXN57sIHUW0A1cQFnoECBkQAQ&url=https%3A%2F%2Fforum.opencart.com%2Fdownload%2Ffile.php%3Fid%3D33732&usg= AOvVaw0LKV9JkS-OTzi0nBgvpjnI

于 2021-12-30T15:03:30.017 回答
0

最后我从这个来源找到了我的问题的解决方案。

https://medium.com/@soni.manthan0/ups-api-get-estimated-delivery-date-456f00e70742

根据上面的链接,它说它需要在部分中添加新<InvoiceLineTotal>部分并且在<shipment>部分中<city>是必需的<ShipTo>

于 2021-12-30T19:25:11.090 回答