After several attempts, this finally works. The previously posted solutions work if you only need to fulfill the entire order. This process takes into account back-ordered items as well. So this code will only fulfill line items that shipped and not automatically fulfill the entire order.
Sorry for any confusion, I thought it was working when the orders were fulfilled and then I realized the code was fulfilling the entire order including out-of-stock items. All fixed now.
Again, thank you everyone for your input and patience!
Step One:
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Step Two: Parse the return for the following details
In the return, look for the column with the array in it and parse out the array. There are several columns of data needed from this array. Some of them are also outside of the array, but some are not. The array is called “api.fulfillment_orders line_items”. The columns you need, depending on your requirements, are:
api.fulfillment_orders id = fulfillment_orders_id
api.fulfillment_orders assigned_location_id = location_id
api.fulfillment_orders order_id = order_id
api.fulfillment_orders line_items variant_id = variant_id
api.fulfillment_orders line_items id = line item identifier needed for your ship quantity array
Admittedly, there may have been something with the way I pulled in this data that caused the array to occur. So you may not have to parse out the data, but in case you do, those are the details. After that, put together an array with your shipping info (only if you need it).
{"id": {api.fulfillment_orders line_items id}, "quantity": {Quantity Shipped}}
Step Three: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.fulfillment_orders id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.fulfillment_orders assigned_location_id}
}
}