Covers all questions related to inventory management, order fulfillment, and shipping.
Hi,
I'm trying to fulfil an order in Shopify using a RESTful API.
The one I have been using is
POST: https://{StoreName}.myshopify.com/admin/api/2022-07/orders/{fulfillmentID}/fulfillments.json
BODY:
{ "fulfillment": { "line_items_by_fulfillment_order": [ { "fulfillment_order_id": {ID} } ], "notify_customer" : false, "location_id": {locationID} } }
The response I'm getting is a 404 - with no content.
I've seen some examples online where they use the tracking Info which I can't find.
I've also assigned read and write abilities for the following (including some for other tasks)
read_products, write_inventory, read_inventory, read_orders, write_orders, write_third_party_fulfillment_orders, read_third_party_fulfillment_orders, write_fulfillments, read_fulfillments, write_merchant_managed_fulfillment_orders, read_merchant_managed_fulfillment_orders, write_assigned_fulfillment_orders, read_assigned_fulfillment_orders, write_custom_fulfillment_services, read_custom_fulfillment_services, write_fulfillment_constraint_rules, read_fulfillment_constraint_rules
If I remove the location ID from the payload the response suggests that the location ID is mandatory so the call must be working.
Is there something missing from my payload or should I be using a different call?
Many Thanks,
Dan
Solved! Go to the solution
This is an accepted solution.
I think you are missing a step. You need to GET request the following:
https://{StoreName}.myshopify.com/admin/api/2022-10/orders/{order_id}/fulfillment_orders.json
This will return a list of fulfillment_order_ids for the shopify order {order_id}.
You can then iterate over these IDs and POST the body you described above to:
https://{StoreName}.myshopify.com/admin/api/2022-07/orders/{fulfillmentID}/fulfillments.json
In the body the fulfillment_order_id is the fulfillment order ID you retrieved in the first GET request above.
The 404 you are getting is because the fulfillment_order_id is not being found by Shopify.
Here's what my payload that is sent to the Fulfillments endpoint looks like:
[
"line_items_by_fulfillment_order" => [
[
"fulfillment_order_id" => $fulfillmentOrderId
],
],
"tracking_info" => [
"number" => $tracking_number,
"url" => $tracking_url,
"company" => $tracking_company,
],
"notify_customer" => true,
"origin_address" => null,
"message" => "Items are shipped."
]
This is an accepted solution.
I think you are missing a step. You need to GET request the following:
https://{StoreName}.myshopify.com/admin/api/2022-10/orders/{order_id}/fulfillment_orders.json
This will return a list of fulfillment_order_ids for the shopify order {order_id}.
You can then iterate over these IDs and POST the body you described above to:
https://{StoreName}.myshopify.com/admin/api/2022-07/orders/{fulfillmentID}/fulfillments.json
In the body the fulfillment_order_id is the fulfillment order ID you retrieved in the first GET request above.
The 404 you are getting is because the fulfillment_order_id is not being found by Shopify.
Here's what my payload that is sent to the Fulfillments endpoint looks like:
[
"line_items_by_fulfillment_order" => [
[
"fulfillment_order_id" => $fulfillmentOrderId
],
],
"tracking_info" => [
"number" => $tracking_number,
"url" => $tracking_url,
"company" => $tracking_company,
],
"notify_customer" => true,
"origin_address" => null,
"message" => "Items are shipped."
]
I'm having the same issue of not being able to send the fulfillments, and I tried this solution, and it didn't work. The documentation says you should use endpoint
/admin/api/2023-07/orders/fulfillments.json. i.e don't put the fulfillment id in the url. When I do that it returns no errors but doesn't do it. So I added the fulfillment id per your suggestion and it now says. "Not Found". I then changed the 2023 to be 2022 and it still returns "Not Found". I verified the Fulfillment ID again and it is correct. Any ideas?
Hi @RobertM ,
I've managed to get the call working. A couple of things to check are:
I use postman client to test the API calls - the first call was as @Milkbottlelough suggested https://{ShopName}.myshopify.com/admin/api/2023-07/orders/{OrderId}/fulfillment_orders.json
from the response you will want to use the id
from this if you do a POST call to https://{shopname}.myshopify.com/admin/api/2023-07/fulfillments.json
with your shopify access token and content-type set to application/json and a body similar to this:
Thank you Dan, Your reply was the answer, and I got it to work. The URL in the accepted solution does not work. It was
https://{StoreName}.myshopify.com/admin/api/2022-07/orders/{fulfillmentID}/fulfillments.json.
In your solution, the URL was
https://{StoreName}.myshopify.com/admin/api/2022-07/fulfillments.json
i.e. the /orders/{fulfillmentid} was removed and that does work. I had the correct GET part, but not the POST. Thank you for clarifying how to do it. I'm going to try to add tracking information now.
Robert.
You are absolutely correct, typo on my part in the second URL - apologies.
I tried to edit my answer but I can't as it's the accepted solution. For anyone in the future who wanders on here the corrected urls in my solution are:
GET
https://{StoreName}.myshopify.com/admin/api/2022-10/orders/{order_id}/fulfillment_orders.json
POST
https://{StoreName}.myshopify.com/admin/api/2022-07/fulfillments.json
Thanks for correcting the accepted solution. I used the 2023-07 api, and it worked too.
Hi @Milkbottlelough ,
Thank you for getting back to me. I've now managed to get this working. You were right I think I was using the wrong fulfilment order id in the call.
Everything looks to be working OK now.
Thank you for your help.
Kind Regards,
Dan
Delighted to hear that!
Things have certainly become that bit more complicated on the API side of things when it comes to fulfillments but I guess that was inevitable as partial fulfilment functionality must have been a real head-scratcher for the Shopify devs to roll out without breaking lots of things already in the wild!
Best of luck with the rest of your project!
How did you mange this? As soon as we send in the initial fulfilment Shopify closes the fulfilment and rebuffs any further event or fulfilment messages with a "fulfilment closed" message and doesn't alter the state nor update the customer. This means that once the fulfilment has been sent with tracking info and carrier, we cannot inform the customer of out for delivery or delivered