Showing results for 
Search instead for 
Did you mean: 

Order Shipment using REST API

Order Shipment using REST API


I am hoping that someone is able to assist me with a problem that I am having programatically shipping an order where I pass the items in the request.  I need to do this because sometimes we ship different parts of an order from different warehouses.  I know that I can get it to work when I don't specify the items, however it ships the entire order and this isn't going to work for us 100% of the time.


My integration software is written in C#.


Here is a basic example which I am using to test.

I am calling:
CreateM2Shipment("46671", "AUSTRALIA POST", "AUS123456", new Dictionary<string, int>() { { "4902", 1 } });


public bool CreateM2Shipment(string OrderID, string CarrierName, string ConsignmentID, Dictionary<string, int> Items)
RestClient client = CreateRestClient("");
RestRequest request = CreateRequest("/rest/V1/order/" + OrderID + "/ship", Method.POST);


string items = "\"items\": [";
foreach (KeyValuePair<string, int> kvp in Items)
       items += "{\"order_item_id\": " + kvp.Key.ToString() + ", \"qty\": " + kvp.Value.ToString() + "},";
items = items.Substring(0, items.Length - 1) + "]";


string json = "{ " + items + ", \"tracks\": [ { \"track_number\": \"" + ConsignmentID +"\", \"title\": \"" + CarrierName + "\", \"carrier_code\": \"" + MapCarrier(CarrierName, false) + "\" } ] }";


request.AddHeader("Accept", "application/json");
request.AddParameter("application/json", json, ParameterType.RequestBody);

var result = client.Execute(request);
if (result.StatusCode == System.Net.HttpStatusCode.OK)
      return true;
      return false;



The json string being passed is this:


"items": [{"order_item_id": 4902, "qty": 1}],

"tracks": [{ "track_number": "AUS123456", "title": "AUSTRALIA POST", "carrier_code": "tracker1"}]




Whatever I do I always get the result

StatusCode: BadRequest

Message: Shipment Document Validation Error(s). You can't create a shipment without products.



I have googled and been through every page where others have noted this as an issue and the only answer I can find is to omit the items and it will ship.  It will, but it ships the whole order and I need to ship in parts.


If anyone has any ideas how to get this working, I would very much appreciate any ideas or suggestions.