API UPS 不返回邮政编码和重量

问题描述 投票:0回答:1

关于文档 https://developer.ups.com/api/reference?loc=en_US#operation/getSingleTrackResponseUsingGET

我们可以在响应中包含

postalCode
和重量,但是当我尝试使用UPS的API时,却没有。

curl -i -X GET \
  'https://onlinetools.ups.com/api/track/v1/details/1Z0088XW0360412370?locale=en_US&returnSignature=true' \
  -H 'Authorization: Bearer ......' \
  -H 'Content-Type: application/json' \
  -H 'transId: test123' \
  -H 'transactionSrc: prod'

我有这样的回应:

{"trackResponse":{"发货":[{"inquiryNumber":"1Z0088XW0360412370","package":[{"trackingNumber":"1Z0088XW0360412370","deliveryDate":[{"type":"DEL"," date":"20230405"}],"deliveryTime":{"type":"DEL","endTime":"113010"},"activity":[{"location":{"address":{"city" :"NORTH HIGHLANDS","stateProvince":"CA","countryCode":"US","country":"US"},"slic":"9581"},"status":{"type":" D","描述":"已送达","代码":"9E","statusCode":"011"},"日期":"20230405","时间":"113010"},{"位置": {"address":{"city":"西萨克拉门托","stateProvince":"CA","countryCode":"US","country":"US"},"slic":"9581"}," status":{"type":"I","description":"今天发货","code":"OT","statusCode":"021"},"date":"20230405","time ":"092430"},{"location":{"address":{"city":"西萨克拉门托","stateProvince":"CA","countryCode":"US","country":"US" },"slic":"9589"},"status":{"type":"I","description":"在 UPS 设施处理","code":"YP","statusCode":"071" },"date":"20230405","time":"043623"},{"location":{"address":{"city":"西萨克拉门托","stateProvince":"CA","countryCode" :"US","country":"US"},"slic":"8959"},"status":{"type":"I","description":"到达设施","code": "AR","statusCode":"005"},"date":"20230405","time":"021100"},{"location":{"address":{"city":"Sparks"," stateProvince":"NV","countryCode":"US","country":"US"},"slic":"8959"},"status":{"type":"I","description": "从设施出发","code":"DP","statusCode":"005"},"date":"20230404","time":"235100"},{"location":{"address": {"city":"Sparks","stateProvince":"NV","countryCode":"US","country":"US"},"slic":"8959"},"status":{"type ":"I","描述":"原点扫描","代码":"OR","statusCode":"005"},"日期":"20230404","时间":"204555"},{ "location":{"address":{"countryCode":"US","country":"US"}},"status":{"type":"M","description":"发件人创建了标签, UPS 尚未收到包裹。 ","code":"MP","statusCode":"003"},"date":"20230405","time":"022029"}],"currentStatus":{"description":"已送达", "code":"011"},"packageAddress":[{"type":"ORIGIN","address":{"city":"SPARKS","stateProvince":"NV","countryCode":"US ","country":"US"}},{"type":"DESTINATION","address":{"city":"NORTH HIGHLANDS","stateProvince":"CA","countryCode":"US" ,"country":"US"}}],"service":{"code":"518","levelCode":"003","description":"UPS Ground"},"packageCount":6}] }]}}

我需要像文档一样的目的地

postalcode
和包裹的重量,但回复中没有。

你知道为什么吗?我是否遗漏了一些参数?

response tracking postal-code ups
1个回答
0
投票

这对于解决问题并没有多大帮助,但我就 API 响应中缺少的重量问题联系了 UPS 的支持人员,他们给我发送了以下回复:

感谢您的回复。目前,OAuth 跟踪 API 中并非所有选项都可用于显示信息。在未来的增强功能中,该信息将可用。

所以他们还没有实现所有字段。

更新:

看起来他们现在已经开始使用额外的字段了。重量位于 trackResponse->shipment[i]->package[i]->weight 的响应中,目的地邮政编码是 trackResponse->shipment[i]->package[i]-> 中地址数组的一部分packageAddress 然后你循环遍历这些以找到 type="DESTINATION" 的一个,然后是地址->邮政编码。

这是删除其他跟踪信息的示例:

{
  "trackResponse": {
    "shipment": [
      {
        ...
        "package": [
          {
            ...
            "packageAddress": [
              ...
              {
                "type": "DESTINATION",
                "name": "COMPANY NAME",
                "attentionName": "ATTENTION NAME",
                "address": {
                  "addressLine1": "123 Fake St",
                  "addressLine2": "",
                  "city": "Springfield",
                  "stateProvince": "IL",
                  "postalCode": "62629",
                  "countryCode": "US",
                  "country": "US"
                }
              }
            ],
            "weight": {
              "unitOfMeasurement": "LBS",
              "weight": "14.00"
            },
            ...
          }
        ],
        ...
      }
    ]
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.