Fulfillment.json is not fulfilling order

brentonMN
Shopify Partner
10 0 5

 

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.

Replies 4 (4)

garyrgilbert
Shopify Partner
397 40 162

Hi There,

 

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

 

Cheers,

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
brentonMN
Shopify Partner
10 0 5
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-fulfillmen...
garyrgilbert
Shopify Partner
397 40 162

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-fulfi... 

e.g. 

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

 

Then from that you fill in your post request.

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
brentonMN
Shopify Partner
10 0 5
I have been using Fulfillment Orders API to get them. That is the line_item
data from my results being fed back in.