Cannot save Fulfillment => undefined method 'each' for nil

Does anybody know what might be causing this problem? I’m trying to save a Fulfillment and getting this error
NoMethodError (undefined method `each’ for nil:NilClass)
Code is this

fulfillment = ShopifyAPI::Fulfillment.new
        fulfillment.message = "The package will ship within 1 business day."
        fulfillment.notify_customer = true
        fulfillment.tracking_info = {
          "number" => tn,
          "company" => tc
        }
        fulfillment.line_items_by_fulfillment_order = [
          {
            "fulfillment_order_id" => fulfillment_order.id
          }
        ]
        fulfillment.save!
1 Like

In the

fulfillment.line_items_by_fulfillment_order 

You need to add

“fulfillment_order_line_items” => [
{
“id” => ,
“quantity” =>
}

https://shopify.dev/api/admin-rest/2022-10/resources/fulfillment#post-fulfillments

Figured it out. The issue was that the FulfillmentOrder was not accepted yet. Once I accepted it, the error went away and the Fulfillment was able to save.

1 Like

hi @doughty I have same problem, I have a question.

What do you mean “FulfillmentOrder was not accepted yet”?

How can I confirm and accept it?

Thank you.

Hi @lytiuha :waving_hand:

You’ll need to first accept the fulfillment order as shown in this doc here using POST fulfillment_request/accept in REST or fulfillmentOrderAcceptFulfillmentRequest mutation with GraphQL.

Hope that helps!

1 Like