Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Tracking_number
string ls_Status_code
string ls_Status_description
string ls_Carrier_status_code
string ls_Carrier_status_description
string ls_Ship_date
string ls_Estimated_delivery_date
string ls_Actual_delivery_date
string ls_Exception_description
string ls_Events
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Http.SetRequestHeader("API-Key","{{API_KEY}}")
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://api.shipengine.com/v1/labels/se-123456/track",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "tracking_number": "9405511899564298877610",
// "status_code": "NY",
// "status_description": "Not Yet In System",
// "carrier_status_code": "-2147219283",
// "carrier_status_description": "A status update is not yet available for this tracking number. More information will become available when USPS receives the tracking information, or when the package is received by USPS.",
// "ship_date": null,
// "estimated_delivery_date": null,
// "actual_delivery_date": null,
// "exception_description": null,
// "events": null
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Tracking_number = loo_JResp.StringOf("tracking_number")
ls_Status_code = loo_JResp.StringOf("status_code")
ls_Status_description = loo_JResp.StringOf("status_description")
ls_Carrier_status_code = loo_JResp.StringOf("carrier_status_code")
ls_Carrier_status_description = loo_JResp.StringOf("carrier_status_description")
ls_Ship_date = loo_JResp.StringOf("ship_date")
ls_Estimated_delivery_date = loo_JResp.StringOf("estimated_delivery_date")
ls_Actual_delivery_date = loo_JResp.StringOf("actual_delivery_date")
ls_Exception_description = loo_JResp.StringOf("exception_description")
ls_Events = loo_JResp.StringOf("events")
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X GET
-H "API-Key: {{API_KEY}}"
https://api.shipengine.com/v1/labels/se-123456/track
Postman Collection Item JSON
{
"name": "Track using a label ID",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/labels/{{label_id}}/track",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"labels",
"{{label_id}}",
"track"
]
},
"description": "If you created the shipping label using ShipEngine, then tracking a package is even easier. No need to specify the `carrier_code` and `tracking_number`. All you need is the `label_id`."
},
"response": [
{
"name": "Track using a label ID",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/labels/{{label_id}}/track",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"labels",
"{{label_id}}",
"track"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 18 Sep 2019 18:53:59 GMT"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Content-Length",
"value": "531"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Access-Control-Allow-Origin",
"value": "https://www.shipengine.com"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "x-shipengine-requestid",
"value": "853bc684-6123-43aa-91ab-5ce1a8da908b"
}
],
"cookie": [
],
"body": "{\n \"tracking_number\": \"9405511899564298877610\",\n \"status_code\": \"NY\",\n \"status_description\": \"Not Yet In System\",\n \"carrier_status_code\": \"-2147219283\",\n \"carrier_status_description\": \"A status update is not yet available for this tracking number. More information will become available when USPS receives the tracking information, or when the package is received by USPS.\",\n \"ship_date\": null,\n \"estimated_delivery_date\": null,\n \"actual_delivery_date\": null,\n \"exception_description\": null,\n \"events\": null\n}"
}
]
}