0

a bit lost, I'm attempting to use

{SiteUrl}/rest/V1/order/{id}/ship

using litterally the request found here:

{
  "tracks": [
    {
      "track_number": "1Y-9876543210",
      "title": "Custom",
      "carrier_code": "SomeCarrierCode"
    }
  ]
}

The answer at the bottom, and several others I have seen imply that this should be sufficient to create a shipment via the url provided, and funnily enough while postman doesn't save the responses like the Talend plugin does, I was certain I was using this code via postman to correctly submit to two different Magento sites.

Today i finally worked out an issue with my code that was stopping me from posting these, and curiously even going back into postman i am now getting the following response

{
    "message": "Shipment Document Validation Error(s):\nThe order does not allow a shipment to be created.\nYou can't create a shipment without products."
}

I have tried on both a completed order (one that previously worked) and 2 new orders with completed invoices.

Can anyone suggest where I might be going wrong? (I am confident I have the Oauth Correct because getOrders is working.

1 Answer 1

1

Please refer to https://magento.redoc.ly/2.4.3-admin/tag/orderorderIdship#operation/salesShipOrderV1ExecutePost

Full payload example:

{
    "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": {
            "source_code": "string"
        }
    }
}

... where as per the docs

comment/comment
comment/is_visible_on_frontend
items[]/order_item_id
items[]/qty
tracks[]/carrier_code
tracks[]/title
tracks[]/track_number

are required.

4
  • Thanks, i was really hoping this wasn't the case, as it was.. somehow previously working, without the need to pull the order item ID, which.. I don't seem to have. the only reference to this via the API i can find is the invoice and we aren't generating that to store that ID.
    – R.Dukane
    Mar 4 at 16:51
  • I think you're not wrong - just checked an old implementation of the shipping api of mine, there I didn't specify the items to ship either. Can you check in Magento\Sales\Model\Order\Shipment\Validation\QuantityValidator from where the error response is actually returned (the mentioned string is used twice in there)? Mar 4 at 17:21
  • 1
    baffled.. just created a new order and posted, it works.. admittedly when i went looking at the order to again, try to find these order_item_id's i noted that the order i was posting thought the single item in it, had been despatched... so i tried creating a new order.. maybe this is a problem in testing with my codebase or setup.. ill try a few more this evening, if it works ill mark your answer correct and add my own below stating my findings (i think that way what 99% of people are getting wrong will be the right answer and anyone with this edge case will be covered).. many thanks
    – R.Dukane
    Mar 4 at 18:29
  • Nothing wrong with accepting your own answer as correct if it is applicable to the particular problem you were facing ;) Mar 4 at 18:38

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.