You must be using serialized inventory (or similar), and in that case, the inventory detail information must be provided either on the Item Fulfillment, or on the Sales Order if you are not going through a fulfillment. Try doing it in the UI, and I think you'll get the same error.