Location id must be specified when creating fulfillment

I am sending a request to the fulfillment resource /admin/api/2022-10/fulfillments.json to mark one line item fulfilled.However I keep getting the following error :

"location_id must be specified when creating fulfillments "

I need help with understanding what I might be sending wrong(this is php):

$data = [
    'fulfillment' => [
        'message' => 'Fulfill Attempt',
        'location_id' => 12345,
        'notify_customer' => false,
        'tracking_info' => [
            'number' => 1234567,
            'url' => 'fedex.com',
            'company' => 'fedex',
        ],
        'line_items_by_fulfillment_order' => [
            [
                'fulfillment_order_id' => $fulfillmentOrderId,
                'fulfillment_order_line_items' => [
                'line_item_id' => $lineItemId,
                'quantity' => 1,
                ],
            ],
        ],
    ],
];

I have tried adding location_id in different spots. Some help with this will be much appreciated. I have also tried /admin/api/2022-07/fulfillments.json

When I add location_id, I get a 404 response.

Without location_id, I receive the same 400 error “location_id must be specified when creating fulfillments”.

Example args:

{ "line_items_by_fulfillment_order":[{"fulfillment_order_id":5700827480123,"fulfillment_order_line_items":[{"id":13047016030267,"quantity":1}]}],"notify_customer":true,"tracking_info":{"company":"FedEx","number":"392463695700"} }

I have the same issue using the admin api 2022-10. It doesnt matter if there is a location_id set in the fulfillment array or not, the error is still the same: [error] => location_id must be specified when creating fulfillments. Would be great to get an answer from the shopify pros soon :slightly_smiling_face:

This is the JSON schema that I used to create the fulfillment for orders and it worked.

{
  "fulfillment": {
    "location_id": 00000000000,
    "line_items_by_fulfillment_order": [
      {
        "fulfillment_order_id": 00000000000,
        "fulfillment_order_line_items": [
          {
            "id": 00000000000,
            "shop_id": 00000000000,
            "fulfillment_order_id": 00000000000,
            "quantity": 1,
            "line_item_id": 00000000000,
            "inventory_item_id": 00000000000,
            "fulfillable_quantity": 1,
            "variant_id": 00000000000
          }
        ]
      }
    ],
    "tracking_info": {
      "company": "Fedex",
      "number": "00000000000",
      "url": "https://www.fedex.com/fedextrack/
trknbr=00000000000&trkqual=00000~00000000000~FDEG"
    },
    "notify_customer": true
  }
}

I just simply can’t get it. Is it so difficult to describe all mandatory fields for the request?

Why was it documented so badly here: https://shopify.dev/docs/api/admin-rest/2023-04/resources/fulfillment#post-fulfillments ?
Even in the request example there is no location_id set. And this is only 1 example. Almost every endpoit in shopify rest api documentation has some missing property, that are required for particular request.

Hi @maddos :waving_hand:

Thanks for the feedback, we’re always looking to improve our docs and would really appreciate you also submitting feedback directly in the docs. There should be a “Was this section helpful?” block, and once you click “No”, there will be a section to comment on how it can be improved.

For the POST request to the fulfillments.json endpoint, it shouldn’t require a location_id to create a fulfillment. If you’re using the Shopify PHP library, I’d recommend submitting an issue in the public repo here.

Thank you for your response, but unfortunately the request example that you provide dosen’t work.

Here is my example

REQUEST:

{
“fulfillment”: {
“tracking_info”: {
“company”: “DHL”,
“number”: “222201010030243431”
},
"notify_customer ": true,
“line_items_by_fulfillment_order”: [
{
“fulfillment_order_id”: 4806734774445,
“fulfillment_order_line_items”: [
{
“id”: 12225550549165,
“quantity”: 1,
}
]
}
]
}
}

RESPONSE:

(POST https://{user}:{pw}@{shop}.myshopify.com/admin/api/2023-01/orders/4806734774445/fulfillments.json) 400

body: {“error”:“location_id must be specified when creating fulfillments.”}

Thank you for your response, unfortunately the request example that you provide doesn’t work.

Here is my example:

{
“fulfillment”: {
“tracking_info”: {
“company”: “DHL”,
“number”: “222201010030243431”
},
"notify_customer ": true,
“line_items_by_fulfillment_order”: [
{
“fulfillment_order_id”: 4806734774445,
“fulfillment_order_line_items”: [
{
“id”: 12225550549165,
“quantity”: 1,
“line_item_id”: null,
“fulfillment_order_id”: null
}
]
}
]
}
}

And Response that I’m getting:

Status 400,

body: {“error”:“location_id must be specified when creating fulfillments.”}

But even, if i set the location_id field, i’m getting another error:

Status 404,

message: “No content to map due to end-of-input”

How should i find out what fields are mandatory?

Thank you.

Thank you for your response, unfortunately the request example that you provide doesn’t work.

Here is my request example:

{
"fulfillment": {
"tracking_info": {
"company": "DHL",
"number": "222201010030243431"
},
"notify_customer ": true,
"line_items_by_fulfillment_order": [
{
"fulfillment_order_id": 4806734774445,
"fulfillment_order_line_items": [
{
"id": 12225550549165,
"quantity": 1,
"line_item_id": null,
"fulfillment_order_id": null
}
]
}
]
}
}

And Response that I’m getting:

Status 400,

body: {"error":"location_id must be specified when creating fulfillments."}

But even, if i set the location_id field, i’m getting another error:

Status 404,

message: “No content to map due to end-of-input”

How should i find out what fields are mandatory?

Thank you.