Trying to fulfil a specific item in an order

Trying to fulfil a specific item in an order

brentonMN
Shopify Partner
10 0 5
I'm trying to get through with support on what seems like an on-going issue in the Shopify Dev Forums. (This is the page: https://shopify.dev/docs/api/admin-rest/2023-04/resources/fulfillment#post-fulfillments). 
I have an app that I've made that is trying to automatically fulfil certain products in orders.
 
I have:
  • Setup the correct permissions for the custom app.
  • Every other request performed via app is working.
Error returned is: "{ errors: { fulfillment: 'Required parameter missing or invalid' } }".

 

This is the item data I am fetching off 'fulfillment_orders.json':

 

{
  id: ######,
  shop_id: ######,
  fulfillment_order_id: ######,
  quantity: 1,
  line_item_id: ######,
  inventory_item_id: ######,
  fulfillable_quantity: 1,
  variant_id: ######
}

 


This is my script I am using to try and update the item as fulfilled using 'fulfillments.json':

 

var jsonData = {
  "fulfillment": {
     "line_items_by_fulfillment_order": [{
        "fulfillment_order_id": item.fulfillment_order_id,
        "line_items": [{"id": item.id"quantity": item.quantity}]
      }],
  "notify_customer": false,
 }
};
var req = await unirest.post(`${process.env.BASE_URL}/admin/orders/${orderID}/fulfillments.json`,{
  'X-Shopify-Access-Token': process.env.API_KEY,
  'Accept': 'application/json',
  'Content-Type': 'application/json'
})
.send(JSON.stringify(jsonData))
.end(function (response) {
  console.log(response.body);
});
 
Reply 1 (1)

garyrgilbert
Shopify Partner
414 41 170

Hi There,

 

Close but not quite, refer to the documentation for the right structure of the json. I'll give you a "hint" though.. its "fulfillment_order_line_items" and not "line_items".

 

fulfillment.line_items_by_fulfillment_order = [
  {
    "fulfillment_order_id": 1046000849,
    "fulfillment_order_line_items": [
      {
        "id": 1058737608,
        "quantity": 1
      }
    ]
  }
];

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution