Magento2: Rest salesShipOrderV1 API w/ Bundles error: "You can't create a shipment without products"

Created on 25 May 2017  Â·  31Comments  Â·  Source: magento/magento2


Preconditions


  1. Magento v2.1.4
  2. 2.

Steps to reproduce

  1. Create an order containing a bundle of multiple simple products.
  2. Call the REST salesShipOrderV1 API (POST /V1/order/{orderId}/ship) and send a shipment for the individual items. Example:
{
        "appendComment": 1,
        "notify": 1,
        "comment": {
            "comment": "Your order has been shipped, login to view tracking information.",
            "is_visible_on_front": 1
        },
        "items": [
            {
                "order_item_id": 516,
                "qty": 1
            },
            {
                "order_item_id": 517,
                "qty": 1
            }
        ],
        "tracks": [
            {
                "title": "Netherlands Post Ground Parcel",
                "carrier_code": "custom",
                "track_number": "3SCEMW182389201"
            }
        ]
}

Expected result

  1. Order gets mark completed

Actual result


1.

{
        "status": 400,
        "headers": {},
        "body": {
            "message": "Shipment Document Validation Error(s):\nYou can't create a shipment without products."
        }
}

Additional info

Reproduced it via Swagger.
Applied admin token and used the __POST/V1/order/{orderId}/ship__
Used the following query body

{
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 6,
      "qty": 1
    }
  ],
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "Your order has been shipped, login to view tracking information.",
    "is_visible_on_front": 1
  },
  "tracks": [
    {
      "extension_attributes": {},
      "track_number": "3SCEMW182389201",
      "title": "Netherlands Post Ground Parcel",
      "carrier_code": "fixed"
    }
  ],
  "packages": [
    {
      "extension_attributes": {}
    }
  ],
  "arguments": {
    "extension_attributes": {}
  }
}

Where :

  • orderId can be found in __Sales - Orders__
    sales_orders
  • track_number is set while Shiping the order
    ship
    Add a tracking number
    track_number
  • order_item_id I'm sure that there is an easier way, but I used GraphQL to verify the order item id
    order_item_id
CD FrameworWebapi Sales Clear Description Confirmed Format is valid Ready for Work P1 done Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x Reproduced on 2.4.x S1 Dev.Experience

Most helpful comment

Hello,

I'm curious myself when this issue will be solved?

Kind regards,
Reijer

All 31 comments

Hi, @jim5359, according to your request log, it seems you are sending the simple products to shipment but you need to set order_item_id as item_id of the bundle product NOT a simple.

As a shipper I'm physically shipping the individual simple products, not the bundle SKU. The bundle SKU is just a virtual SKU representing the simple products. So I'm just telling Magento 2 what was actually shipped. It seems Magento 2 should be able to handle this and be smart enough to know once all the simple products are shipped then the bundle is shipped also. This is how it works in Magento 1 when sending shipments. We only ever send shipments for simple products and it works just fine.

How would we handle the scenario where the simple products were shipped separately? Each would have their own tracking number. If we can only mark the virtual bundle sku as shipped then it seems this scenario could not be handled.

Thanks.

Hello,

I'm curious myself when this issue will be solved?

Kind regards,
Reijer

Looking forward to fix this asap as its blocking major development from us :)

Hi I am facing the same issue, below is my request format

  params = {
        items: [
            {
                order_item_id: 5,
                qty: 1
            }
        ],
        tracks: [
            {
                carrier_code: "UPS",
                title: "ground",
                track_number: 12345678
            }
        ]
    }

and i get the error as Shipment Document Validation Error(s):\nA shipment cannot be created when an order has a status of new\nYou can't create a shipment without products.

HI, i am also facing the same issue
{"message":"Shipment Document Validation Error(s):\nYou can't create a shipment without products.\nPlease enter a tracking number.

json:

{
"items": {
"extension_attributes": null,
"order_item_id": 9,
"qty": 2.0,
"sku": "Pen"
},
"notify": true,
"appendComment": true,
"comment": {
"comment": "first Shipment",
"is_visible_on_front": 0
},
"tracks": {
"track_number": "123456",
"title": "05SHIPMENT",
"carrier_code": "dhl"
},
"packages": null,
"arguments": null
}

I have this same issue and I am not shipping bundled items.
I am testing with an order with one simple item.
This is holding up development. An alternative method to add tracking would be helpful.

i solved it.
You need to use the REST API "/rest/V1/order/incrementid/ship"
Instead of this public IList Items { get; set; }
write this in property
public List Items = new List();

for (int piOrderQtyCnt = 0; piOrderQtyCnt < dtDelivery.Rows.Count; piOrderQtyCnt++)
{
var item = new Ship.Item();
item.OrderItemId = int.Parse(dtDelivery.Rows[piOrderQtyCnt]["MagentoItem"].ToString());
item.Qty = double.Parse(dtDelivery.Rows[piOrderQtyCnt]["Quantity"].ToString());

      postshipment.Items.Add(item);

      postshipment.Tracks = new List<Ship.Track> {
    new Ship.Track {TrackNumber = dtDelivery.Rows[piOrderQtyCnt]["TrackNo"].ToString(),CarrierCode="dhl"},
              };
          }

Then post the shipment through REST API.You will not get the error.

@Monika1802
I had the correct format to my post. The issue seems to be with the type of payment method. Money order works find but authorize.net (credit card) gives the issue.

It seems this issue has gotten off track. This issue is specifically with trying to ship partial bundles. The salesShipOrderV1 works fine for individual items and complete bundles. If you are having problems with non-bundles please create a separate issue so this one doesn't get diluted and confused.

Is there a solution for this? I am using NetSuite with the FarApp integration for Magento and get the error ‘you can’t create a shipment without any products’ when trying to update products

I am on Magento 2.2.2.
Php 7.0

Hello everyone,

Can someone help to find out the solution to my problem?
I can not create partial shipment here is my JSON format

{

"items":
[
    {

        "order_item_id": 3,
        "qty":1

    }
],
    "notify":true,
    "appendComment":false,
    "tracks":
    [
        {
            "track_number":"012356",
            "title":"",
            "carrier_code":"fedex"

        }
    ]

}

response:-"message": "Shipment Document Validation Error(s):\nYou can't create a shipment without products.",

@jim5359 have you found the solution for shipment

@shweta1234567 Unfortunately, not. Most of our customers are sticking with Magento 1 for this and other reasons.

If this issue is so critical to hold us from migrating to M2, it should be prioritized very high !!!!

Any updates regarding this?

Bump

Is there any updates to this issue? I'm hitting a development roadblock as well.

We just hit this issue as well in migrating to M2. Is this still not fixed?

@magento-engcom-team Any solution to this.
I having to end up using 2 call.
1- to create ship/V1/shipment
2- to add tracking /V1/shipment/track

As /V1/shipment has an option to add Tracks but also not adding ?
ref:https://devdocs.magento.com/redoc/2.3/admin-rest-api.html#operation/salesShipmentRepositoryV1SavePost
Thanks

I have recently determined that the item visibility has something to do with this issue.
One of my clients has items that are only visible via sku search and I can not add tracking to these items.

If possible the actual error logs sometimes have more information. You normally need access to the server to see these but it could offer insights

Dan

Sent from my iPhone

On Mar 29, 2019, at 7:58 AM, Juliano Vargas notifications@github.com wrote:

@magento-engcom-team Any solution to this.
I having to end up using 2 call.
1- to create ship /V1/shipment
2- to add tracking /V1/shipment/track

As /V1/shipment has an option to add Tracks but also not adding ?
ref:https://devdocs.magento.com/redoc/2.3/admin-rest-api.html#operation/salesShipmentRepositoryV1SavePost
Thanks

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Hi, @jim5359, according to your request log, it seems you are sending the simple products to shipment but you need to set order_item_id as item_id of the bundle product NOT a simple.

This issue is still persisting,I did all the essential steps but not able to succeed yet. Can anyone help me out please.

If this issue is so critical to hold us from migrating to M2, it should be prioritized very high !!!!

This issue is still persisting,I did all the essential steps but not able to succeed yet. Can anyone help me out please. It is quite frustrating

Similar to bundles...configurable items sort of have a similar issue. You can't post the order_item_id of the simple product, you have to post the order_item_id of it's parent, the configurable item. This also seems a bit off as its not truly what you are shipping. The configurable item is just a high level grouping item, not a true sku. i.e. a Denver Broncos T-Shirt is the configurable item, the Small size is the simple product underneath it, which is an actual sku that you inventory and ship.

(A related side question, why does retrieving orders include both the
- configurable item
- simple item that is under this same configurable item
- parent item, which is also the same top level configurable item

You get 3 item objects when really there is just one item on the order? Seems like a lot of extra and redundant data to pass back over the wire!)

Hi @engcom-Bravo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


:white_check_mark: Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets MC-30348 were created

Issue Available: @engcom-Bravo, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

@shweta1234567 @jim5359

I think the issue is opened due to an miss-understanding the items_id is not the product id instead it is the item_id of the product to ship in table sales_order_item

I do faces same issue , hope this help someone

Just tested this, and yes, it seems you have to pass the parent_item_id if the product is a child of a configurable product, otherwise you get an error

see code example:

if($orderItem->getParentItemId() == null) {
    $setOrderItemId = $orderItem->getItemId();
}
else {
    $setOrderItemId = $orderItem->getParentItemId();
}
$shipmentItem->setOrderItemId($setOrderItemId);
$shipmentItem->setQty($deliveryNoteItem->getQuantity());
$shipmentItems[] = $shipmentItem;

This should definitely be fixed, since logically it would make sense to create shipments for the single product and not the configurable product.

Bump. I do face the same issue

Hi everyone, this is the solution:

{
"appendComment": true,
"notify": true,
"comment":{
"comment":"shipment creado via webservice",
"is_visible_on_front":1
},

    "tracks": [
        {
            "track_number":"3SCEMW182389201",
             "title":"UPS",
             "carrier_code":"Carrier code n"
        }
    ]

}

remove items, it worked for me.

Hi @engcom-Golf. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


    1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

Was this page helpful?
0 / 5 - 0 ratings