0

I need to add carrier code and tracking number to the shipment by REST API.

For this, I am trying 2 different codes which I found from the search as below. But it doesn't update anything, not display any error and return the same array.

  1. I don't know what should be order_id, parent_id and entity_id. I am using different ids from the order and shipment URL.

    $shiptrack = [
    "entity" => [
    "order_id" => 6298,
    "parent_id" => 6298,
    "entity_id" => 12594,
    "weight"=> 0,
    "qty"=> 0,
    "description"=> "Tracking code Description",
    "track_number"=> "1234567",
    "title"=> "Custom Tracking Code",
    "carrier_code"=> "custom"
    ]
    ];
    

2.Tried all ids from the order and shipment URL.

$shiptrack = [ 
"items"=> [ 
        [ 
            "order_item_id"=>5813, 
            "qty"=> 0 
        ] 
    ], 
"notify" => true, 
"appendComment" => true, 
"comment" => [ 
    "extension_attributes" => [], 
    "comment" => "Item(s) has been shipped", 
    "is_visible_on_front" => 0 
], "tracks" => [ 
        [ 
            "extension_attributes" => [], 
            "track_number" => $trackingNumber, 
            "title" => $shipTitle, 
            "carrier_code" => $carrierCode 
        ] 
    ] 
];
1

Inorder to add tracking information to a shipment you need to make a POST call to the following link

{base_url}/V1/shipment/track

Sample Body :

{
 "entity": {
 "order_id": 291,
 "parent_id": 121,
 "description": "Tracking code Descripton",
 "track_number": "123456789",
 "title": "FEDEX",
 "carrier_code": "fedex"
 }
}

Here order_id is the one you see when you open Order View Page in Admin. See Ref Image, here Red marked is order id. enter image description here

And parent_id is the one you see when you open Shipment View Page in Admin (for which you are going to add tracking info). See Ref Image, here Red marked is parent id. enter image description here

Make sure you do not forget to add Authentication Bearer to header of your request. Hope if finds you helpful.

| improve this answer | |
  • It's worked. Thank you, Abdul. – Jigar Dhaduk Aug 1 '19 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.