2017-08-02 52 views
0

我一直在測試貨件追蹤,並通過我的控制器獲取信息。但是,當我在其他地方添加一行JavaScript代碼時,跟蹤始終返回未知狀態。我不確定跟蹤是否正確,總是返回未知,或者我的代碼出現問題。我有跟蹤器ID存儲,所以我可以隨時在easypost上進行測試。Easypost貨件追蹤問題

這是未知狀態訂單的細節之一。

{ 
 
    "id": "trk_884a31a503b745a7836c9fbed33212d5", 
 
    "object": "Tracker", 
 
    "mode": "test", 
 
    "tracking_code": "9470136897846111103191", 
 
    "status": "unknown", 
 
    "status_detail": "unknown", 
 
    "created_at": "2017-08-02T18:44:24Z", 
 
    "updated_at": "2017-08-02T18:44:24Z", 
 
    "signed_by": null, 
 
    "weight": null, 
 
    "est_delivery_date": null, 
 
    "shipment_id": "shp_7bc893df86a94607b6d85a740a5ed3cb", 
 
    "carrier": "USPS", 
 
    "tracking_details": [], 
 
    "fees": [], 
 
    "carrier_detail": null, 
 
    "public_url": "the url of the label" 
 
}

這是我的一些正常訂單狀態。

{ 
 
    "id": "trk_bbacef9dece94ced96e07a447021d9d9", 
 
    "object": "Tracker", 
 
    "mode": "test", 
 
    "tracking_code": "9461236897846111100762", 
 
    "status": "delivered", 
 
    "status_detail": "arrived_at_destination", 
 
    "created_at": "2017-08-02T18:43:39Z", 
 
    "updated_at": "2017-08-02T18:46:39Z", 
 
    "signed_by": "John Tester", 
 
    "weight": null, 
 
    "est_delivery_date": "2017-08-02T18:46:39Z", 
 
    "shipment_id": "shp_c888e36c1c6b41418160d7d21bcd832a", 
 
    "carrier": "USPS", 
 
    "tracking_details": [ 
 
    { 
 
     "object": "TrackingDetail", 
 
     "message": "Pre-Shipment Info Sent to USPS", 
 
     "status": "pre_transit", 
 
     "status_detail": "status_update", 
 
     "datetime": "2017-07-02T18:46:39Z", 
 
     "source": "USPS", 
 
     "carrier_code": null, 
 
     "tracking_location": { 
 
     "object": "TrackingLocation", 
 
     "city": null, 
 
     "state": null, 
 
     "country": null, 
 
     "zip": null 
 
     } 
 
    }, 
 
    { 
 
     "object": "TrackingDetail", 
 
     "message": "Shipping Label Created", 
 
     "status": "pre_transit", 
 
     "status_detail": "status_update", 
 
     "datetime": "2017-07-03T07:23:39Z", 
 
     "source": "USPS", 
 
     "carrier_code": null, 
 
     "tracking_location": { 
 
     "object": "TrackingLocation", 
 
     "city": "HOUSTON", 
 
     "state": "TX", 
 
     "country": null, 
 
     "zip": "77063" 
 
     } 
 
    } 
 
    ], 
 
    "carrier_detail": { 
 
    "object": "CarrierDetail", 
 
    "service": "First-Class Package Service", 
 
    "container_type": null, 
 
    "est_delivery_date_local": null, 
 
    "est_delivery_time_local": null, 
 
    "origin_location": "HOUSTON TX, 77001", 
 
    "origin_tracking_location": { 
 
     "object": "TrackingLocation", 
 
     "city": "NORTH HOUSTON", 
 
     "state": "TX", 
 
     "country": null, 
 
     "zip": "77315" 
 
    }, 
 
    "destination_location": "CHARLESTON SC, 29401", 
 
    "destination_tracking_location": { 
 
     "object": "TrackingLocation", 
 
     "city": "CHARLESTON", 
 
     "state": "SC", 
 
     "country": null, 
 
     "zip": "29407" 
 
    }, 
 
    "guaranteed_delivery_date": null, 
 
    "alternate_identifier": null, 
 
    "initial_delivery_attempt": "2017-07-05T08:37:39Z" 
 
    }, 
 
    "finalized": true, 
 
    "is_return": false, 
 
    "public_url": "label url", 
 
    "fees": [] 
 
}

回答

0

美國郵政總局不立即開始跟蹤,即使提供了跟蹤代碼。通常,在看到任何有用的status/tracking_details之前,您必須等到包裹進入郵件流。

在你的情況(在這篇文章的時間),美國郵政沒有一個狀態之一:https://tools.usps.com/go/TrackConfirmAction?tLabels=9470136897846111103191

+0

如果在測試環境中測試的跟蹤信息應該是非常快的。這就是我的大部分測試都是如此。我在5分鐘內得到所有結果,甚至交付 – Nello

+0

在測試環境中,您應該使用EasyPost提供的跟蹤代碼(例如:EZ4000000004)創建跟蹤器,如此處所述:https://www.easypost.com/docs/API#測試特定的跟蹤,狀態 – KFunk