1

I am using postman the rest api to create shipping:

http://myMagento/rest/default/V1/shipment

POST:

{
  "entity": {
    "order_id": 5873,
    "shipment_status": 1,
    "store_id": 1,
    "total_qty": 3,
    "items": [
      {
        "parent_id": 5873,
        "price": 4.99,
        "product_id": 3964,
        "row_total": 3.49,
        "sku": "2457-0000",
        "weight": 1.25,
        "order_item_id": 3964,
        "qty": 3
      }
    ],
    "tracks": [
      {
        "order_id": 5873,
        "weight": 1.25,
        "qty": 3,
        "description": "Tracking Updated",
        "track_number": "123456",
        "title": "DHL",
        "carrier_code": "DHL"
      }
    ],
    "comments": [
      {
        "is_customer_notified": 1,
        "comment": "Order Completed",
        "is_visible_on_front": 1
      }
    ]
  }
}

Can someone help with the above it creates the shipping fine but when click action view the error shows: Is this something to do with parent_id inside items ? what would be the parent_id here?

Fatal error: Uncaught Error: Call to a member function getParentItem() 
on null in 
.../vendor/magento/module-shipping/view/adminhtml/templates/view/items.phtml:19

1 Answer 1

1

The parent_id of the shipment item is the entity_id of the shipment and if I understand you correctly you create a new shipment with this request. So you can't now the entity_id of the newly created shipment at that time.

I would suggest to remove the parent_id from the item. The only required fields in the API documentation inside the items array are order_item_id and qty - everything else is optional. I guess the other fields like sku, price etc. will anyway be taken from the corresponding order_item.

2
  • Thanks I found where the problem is! the order_item_id it isn't the order_id or the product_id it should the item_id from table sales_order_item I was basically trying with entity_id from sales_order table which isn't right and yes you are right you don't need to send all the detail but some fields in the shipping grid like ship-to-name wont show. Mar 20, 2019 at 21:07
  • That's right, from your question I didn't realize that it's not clear to you that the order_item_id is the id of the order item and not of the order :-). But you have anyway to remove the parent_id otherwise you will have strange data constellations.
    – HelgeB
    Mar 21, 2019 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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