devdocs: Couldn't save shipment data

When were are trying to create a shipment record with tracks as part of the request it fails with could not save shipment data when parent id field is missing. Here I cannot give parent id field on tracks array as the shipment is not yet saved.

sample data { “entity”: { “orderId” : 40, “items”: [{ “orderItemId” : 72, “qty”: 1 }],

     "tracks": [{
        "carrier_code": "custom",
        "description": "random",
        "order_id": 6,
        "title": "titile1",
        "track_number": "test1234",
        "weight": "0.1"
    }]

}

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (5 by maintainers)

Most upvoted comments

Magento added POST /V1/order/{orderId}/ship in 2.0.10 and 2.1.2. Its payload is

{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 0,
      "qty": 0
    }
  ],
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "string",
    "is_visible_on_front": 0
  },
  "tracks": [
    {
      "extension_attributes": {},
      "track_number": "string",
      "title": "string",
      "carrier_code": "string"
    }
  ],
  "packages": [
    {
      "extension_attributes": {}
    }
  ],
  "arguments": {
    "extension_attributes": {}
  }
}

Also interested in the plan for this. Seems trivial for M2 to save the tracking information after it has created the shipment and fill in the parent_id value itself.

Hi!

Fix it!!!

Step 1: Create invoice https://devdocs.magento.com/guides/v2.4/rest/tutorials/orders/order-create-invoice.html

Step 2: Create ship The orderId is: entity_id from table sales_order URL: host/rest/V1/order/orderId/ship

Body { “entity”: { “orderId”:8961, “store_id”:1, “items”: [ { “order_item_id”: 4723, “qty”: 1 } ] } }

Postman pictures imagen

DataBase imagen

Thanks, @NadiyaS ! And agreed, thanks also to @mujtaba2012 and @srinivasanithin for idenitifying this issue; we really appreciate the community’s help and contributions! @keharper on the Magento DevDocs team will be watching the internal ticket and updating the docs as needed.