Fulfillment.json is not fulfilling order

This my code below:

var req = await unirest.post(`${process.env.BASE_URL}/admin/api/2023-01/fulfillments.json`)
    .headers({
        'X-Shopify-Access-Token': process.env.API_KEY
    })
    .send({
        "fulfillment": {
            "message":"Fulfilled Donation.",
            "line_items_by_fulfillment_order": [
                {
                    "fulfillment_order_id": item.fulfillment_order_id,
                    "fulfillment_order_line_items": [
                        {
                            "id": item.id,
                            "quantity": item.quantity
                        }
                    ]
                }
            ]
        }
    })

However it returns the error:

{ errors: { fulfillment: 'Required parameter missing or invalid' } }

Doesn’t make sense as I’ve done as instructed via the dev docs here.

Hi There,

What is in “Item”? The only thing I can think of is something in your data is not right.

Cheers,

Gary

ITEM is data from fulfillments associated with an order as per this API
call:
https://shopify.dev/docs/api/admin-rest/2023-04/resources/fulfillment#get-orders-order-id-fulfillments

The fulfillments resource is in the past-tense e.g. fulfillments that have already happend. You cant use data from the fulfillments endpoint to fulfill an order. You need to use the fulfillmentorder endpoint.

https://shopify.dev/docs/api/admin-rest/2023-04/resources/fulfillmentorder#get-orders-order-id-fulfillment-orders

e.g.

/admin/api/2023-04/orders/450789469/fulfillment_orders.json

Then from that you fill in your post request.

Cheers,

Gary

I have been using Fulfillment Orders API to get them. That is the line_item
data from my results being fed back in.

1 Like