Invalid ID when doing fulfillmentCreate mutation

I have the following order in my development store:

{
  "id": "gid://shopify/Order/4447441256654",
  "name": "#1052",
  "createdAt": "2025-01-17T17:05:40Z",
  "updatedAt": "2025-01-17T17:05:41Z",
  "displayFulfillmentStatus": "UNFULFILLED",
  "totalPriceSet": {
    "shopMoney": {
      "amount": "10.93",
      "currencyCode": "USD"
    }
  },
  "totalTaxSet": {
    "shopMoney": {
      "amount": "0.9"
    }
  },
  "totalDiscountsSet": {
    "shopMoney": {
      "amount": "0.0"
    }
  },
  "totalShippingPriceSet": {
    "shopMoney": {
      "amount": "0.0"
    }
  },
  "shippingAddress": null,
  "billingAddress": null,
  "lineItems": {
    "edges": [
      {
        "node": {
          "id": "gid://shopify/LineItem/11208984166606",
          "variant": {
            "id": "gid://shopify/ProductVariant/40302120632526",
            "sku": "spatula-6"
          },
          "product": {
            "id": "gid://shopify/Product/6580769489102"
          },
          "quantity": 1,
          "originalUnitPriceSet": {
            "shopMoney": {
              "amount": "5.02"
            }
          },
          "totalDiscountSet": {
            "shopMoney": {
              "amount": "0.0"
            }
          },
          "taxLines": [
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.2"
                }
              }
            },
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.23"
                }
              }
            },
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.02"
                }
              }
            }
          ]
        }
      },
      {
        "node": {
          "id": "gid://shopify/LineItem/11208984199374",
          "variant": {
            "id": "gid://shopify/ProductVariant/40302121156814",
            "sku": "spatula-7"
          },
          "product": {
            "id": "gid://shopify/Product/6580769489102"
          },
          "quantity": 1,
          "originalUnitPriceSet": {
            "shopMoney": {
              "amount": "5.01"
            }
          },
          "totalDiscountSet": {
            "shopMoney": {
              "amount": "0.0"
            }
          },
          "taxLines": [
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.2"
                }
              }
            },
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.23"
                }
              }
            },
            {
              "priceSet": {
                "shopMoney": {
                  "amount": "0.02"
                }
              }
            }
          ]
        }
      }
    ],
    "pageInfo": {
      "hasNextPage": true,
      "endCursor": "eyJsYXN0X2lkIjoxMTIwODk4NDE2NjYwNiwibGFzdF92YWx1ZSI6MTEyMDg5ODQxNjY2MDZ9"
    }
  },
  "fulfillmentOrders": {
    "edges": [
      {
        "node": {
          "id": "gid://shopify/FulfillmentOrder/5429507686606",
          "lineItems": {
            "edges": [
              {
                "node": {
                  "lineItem": {
                    "id": "gid://shopify/LineItem/11208984166606",
                    "variant": {
                      "id": "gid://shopify/ProductVariant/40302120632526",
                      "sku": "spatula-6"
                    },
                    "product": {
                      "id": "gid://shopify/Product/6580769489102"
                    },
                    "quantity": 1
                  }
                }
              },
              {
                "node": {
                  "lineItem": {
                    "id": "gid://shopify/LineItem/11208984199374",
                    "variant": {
                      "id": "gid://shopify/ProductVariant/40302121156814",
                      "sku": "spatula-7"
                    },
                    "product": {
                      "id": "gid://shopify/Product/6580769489102"
                    },
                    "quantity": 1
                  }
                }
              }
            ],
            "pageInfo": {
              "hasNextPage": false,
              "endCursor": "eyJsYXN0X2lkIjoxMTMxMzM5MzY5Njk3NCwibGFzdF92YWx1ZSI6MTEzMTMzOTM2OTY5NzR9"
            }
          }
        }
      }
    ],
    "pageInfo": {
      "hasNextPage": false,
      "endCursor": "eyJsYXN0X2lkIjo1NDI5NTA3Njg2NjA2LCJsYXN0X3ZhbHVlIjoiNTQyOTUwNzY4NjYwNiJ9"
    }
  },
  "fulfillments": []
}

Iā€™m making the following request (doing it without formatting in case it helps):

curl -X POST -H \'Content-Type: application/json\' -H \'X-Shopify-Access-Token: xxx\' -d \'{"query": "\\n            mutation {\\n                fulfillmentCreate(\\n                    fulfillment: {\\n                        trackingInfo: {\\n                            number: \\"1234567890\\",\\n                            url: \\"https://tracking.com\\"\\n                        },\\n                        lineItemsByFulfillmentOrder: [\\n                {\\n                    fulfillmentOrderId: \\"gid://shopify/FulfillmentOrder/5429507686606\\",\\n                    fulfillmentOrderLineItems: [\\n                    {\\n                        id: \\"gid://shopify/LineItem/11208984166606\\",\\n                        quantity: 1,\\n                    }\\n                ]\\n                }\\n            ]\\n                    }\\n                ) {\\n                    fulfillment {\\n                        id\\n                    }\\n                }\\n            }\\n        "}\' https://telescope-test.myshopify.com/admin/api/2024-10/graphql.json'

Pretty-printed, the mutation looks like this:

mutation {
  fulfillmentCreate(
    fulfillment: {
      lineItemsByFulfillmentOrder: [
        {
          fulfillmentOrderId: "gid://shopify/FulfillmentOrder/5429507686606"
          fulfillmentOrderLineItems: [
            { id: "gid://shopify/LineItem/11208984166606", quantity: 1 }
          ]
        }
      ]
    }
  ) {
    fulfillment {
      id
    }
  }
}

As you can see, weā€™re making a request to create a fulfillment for the fulfillment order 5429507686606ā€™s line item 11208984166606. These IDs seem to line up with the node returned from the API.
When I send in this request, I get the following error [{ā€˜messageā€™: ā€˜invalid idā€™, ā€˜locationsā€™: [{ā€˜lineā€™: 3, ā€˜columnā€™: 17}], ā€˜pathā€™: [ā€˜fulfillmentCreateā€™]}]
I donā€™t know how to trace this - what is the wrong ID here? Iā€™m using this as reference: fulfillmentCreate - GraphQL Admin
Thanks!

Hey,

Would you be able to check the status on the fulfillment order if possible

Also in your mutation you are getting the fulfillment id back, but you also need to return the userErrors and check there arenā€™t any.

I checked the status and it looks ā€œOPENā€. Is that not what is to be expected? In the UI for that order I see ā€œFulfill Itemsā€, so I assume itā€™s ready to fulfill.
I queried for the userErrors and that key wasnā€™t passed back. The query part of my mutation looks like:

                    fulfillment {
                        id
                    }
                    userErrors {
                        field
                        message
                    }

Is there anything else I should be doing?

Hi @hnandiwada

By using the order API, you can obtain the fulfillment order information, and in the fulfillment order, you can see the lineitems data

2 Likes

Hi, thanks for showing me a sample response! After looking closely, I see that your response has an ID with FulfillmentOrderLineItem instead of just LineItem. I realized that the line_item entry was for the order line item, not for the fulfillment order line item. Thanks!