Covers all questions related to inventory management, order fulfillment, and shipping.
Issue: Post tracking info to Shopify via API. Previously used admin/api/2020-04/orders/{Order: Id}/fulfillments.json which has been deprecated. Trying to post via admin/api/2021-10/fulfillments.json or /admin/api/2022-07/fulfillments.json without success.
I have been pulling my hair out for a few days now. Reading everything here as well as Shopify Documentation and appear to be no closer to getting this solved. I seem to have this at a point where it is being recognized in some way, but I am now getting this fun error. I have checked my data and ensured that there are no "quantity" : 0 in the data. I am at a loss. Open to suggestions!
@Shopify it would have been really cool if you let us know what method to use to pull in tracking data after you deprecated admin/api/2020-04/orders/{Order: Id}/fulfillments.json because based on my reading there are a lot of us struggling to find a workable replacement.
@Ralph-HA did you manage to find a fix?
UPDATE: I just realized that my issue is I tried to use the "order id" as the fulfillment id. Need to look at the code again. This is the code I used to create the json code. When you look at the sample, the "order id" line is missing.
{ "fulfillment": { "notify_customer": true, "location_id": 18014371875, "tracking_number": {Fulfillments: Tracking Number}, "tracking_url": "{Tracking URL}", "tracking_company": "{Carrier}", "line_items_by_fulfillment_order" : [ { "order_id": {Order: Id}, "fulfillment_order_line_items": [{Line Items Fulfillment Array}] } ] } }
Current error message:
"Fulfillment payloads fulfillment order must be greater than 0"
API Endpoint: admin/api/2021-10/fulfillments.json
Method: POST
"fulfillment": { "line_items_by_fulfillment_order": [ { "fulfillment_order_line_items": [ { "id": 1239874, "quantity": 1 }, { "id": 0983498723, "quantity": 1 }, "order_id": 123456789 } ], "location_id": 98765432, "notify_customer": true, "tracking_company": "Canada Post", "tracking_number": 0123456789, "tracking_url": "https://www.canadapost-postescanada.ca/track-reperage/" } }
For reference, I have read through the following & tried many, many incremental fixes.
https://community.shopify.com/c/fulfillment-api-deprecation/frequently-asked-questions/td-p/1564746
https://shopify.dev/api/admin-rest/2021-10/resources/fulfillment#post-fulfillments
https://shopify.dev/api/admin-rest/2022-07/resources/fulfillment#post-fulfillments
Solved! Go to the solution
This is an accepted solution.
After several attempts, this finally works. The previously posted solutions work if you only need to fulfill the entire order. This process takes into account back-ordered items as well. So this code will only fulfill line items that shipped and not automatically fulfill the entire order.
Sorry for any confusion, I thought it was working when the orders were fulfilled and then I realized the code was fulfilling the entire order including out-of-stock items. All fixed now.
Again, thank you everyone for your input and patience!
Step One:
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Step Two: Parse the return for the following details
In the return, look for the column with the array in it and parse out the array. There are several columns of data needed from this array. Some of them are also outside of the array, but some are not. The array is called "api.fulfillment_orders line_items". The columns you need, depending on your requirements, are:
api.fulfillment_orders id = fulfillment_orders_id
api.fulfillment_orders assigned_location_id = location_id
api.fulfillment_orders order_id = order_id
api.fulfillment_orders line_items variant_id = variant_id
api.fulfillment_orders line_items id = line item identifier needed for your ship quantity array
Admittedly, there may have been something with the way I pulled in this data that caused the array to occur. So you may not have to parse out the data, but in case you do, those are the details. After that, put together an array with your shipping info (only if you need it).
{"id": {api.fulfillment_orders line_items id}, "quantity": {Quantity Shipped}}
Step Three: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.fulfillment_orders id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.fulfillment_orders assigned_location_id}
}
}
Hi @colleenc ,
Not sure if you've solved this, as I see you mentioned using the fulfillment order id. I'll give some guidance if you haven't solved this or if someone else runs into this.
To help give some guidance, here is a restructuring of the request body.
"fulfillment": { "line_items_by_fulfillment_order": [ { "fulfillment_order_id": 123456789,
"fulfillment_order_line_items": [
{
"id": 1239874,
"quantity": 1
},
{
"id": 0983498723,
"quantity": 1
}
] } ],
"tracking_info": {
"company": "Canada Post",
"number": 0123456789,
"url": "https://www.canadapost-postescanada.ca/track-reperage/"
}, "notify_customer": true }
I hope this moves you in the right direction!
Thank you @Ralph-HA! This has been a great help. It looks like I have sorted out how to grab the fulfillment order id, which had been the biggest stopper for me. Thanks for the JSON help. I am going to test everything this morning. Things are finally looking up! I will let you know where I am at and what my final solution is.
Hi @Ralph-HA I have managed to get the API to give me the fulfillment order id.
I think I have my JSON cleaned up properly, and it is going through, it is not failing. However, it is not adding the tracking info to the orders and it is not showing the items as shipped. It's pretty frustrating especially when the old API was so simple - and it was working.
Here is what I am doing:
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order: Id}/fulfillment_orders.json
Which is sending me:
api.id, api.shop_id, api.order_id, etc.
api.id appears to be the fulfillment_order_id as api.order_id is the order_id.
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.assigned_location_id}
}
}
I have check and refreshed the app permissions, so that does not seem to be the issue. I am quite frustrated by this.
Hello my https://fragrance-lodge.myshopify.com/admin/api/2020-04/orders/{Order: Id}/fulfillments.json is not working/has been deprecated armageddon peeps!
With a lot of help from @Ralph-HA @IGIT @SCHLUE1 and others, it is solved.
THIS PROCESS IS WORKING!
Pay attention to the details, as a tiny detail can mess you up for days...ask me how I know...
Step One: GET Fulfillment_Orders API
This step creates the fulfillment and returns the fulfillment_order_id that you need.
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Note: Make sure you use fulfillment_orders and not fulfillments.
This will send you: api.id, api.shop_id, api.order_id, etc., which you need for the next step. Use the api.id for the next step as it is the fulfillment_order_id, do not use api.order_id as it is the order_id.
Step two: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.id},
"line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.assigned_location_id}
}
And that's it! You are done.
Great to see that this working now. Thank you for sharing your findings ColleenC!!
I made an error in the code above, the correct code should include fulfillment_order_line_items and not line_items. I am going to repost my corrected solution. The correct code is:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.assigned_location_id}
}
CORRECTION: My earlier post had an error in the code. It showed line_items instead of fulfillment_order_line_items. The code in this post is correct.
Hello my https://XXX.myshopify.com/admin/api/2020-04/orders/{Order : Id}/fulfillments.json is not working/has been deprecated armageddon peeps!
With a lot of help from @Ralph-HA @IGIT @SCHLUE1 and others, it is solved.
THIS PROCESS IS WORKING!
Pay attention to the details, as a tiny detail can mess you up for days...ask me how I know...
Step One: GET Fulfillment_Orders API
This step creates the fulfillment and returns the fulfillment_order_id that you need.
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Note: Make sure you use fulfillment_orders and not fulfillments.
This will send you: api.id, api.shop_id, api.order_id, etc., which you need for the next step. Use the api.id for the next step as it is the fulfillment_order_id, do not use api.order_id as it is the order_id.
Step two: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.assigned_location_id}
}
This is an accepted solution.
After several attempts, this finally works. The previously posted solutions work if you only need to fulfill the entire order. This process takes into account back-ordered items as well. So this code will only fulfill line items that shipped and not automatically fulfill the entire order.
Sorry for any confusion, I thought it was working when the orders were fulfilled and then I realized the code was fulfilling the entire order including out-of-stock items. All fixed now.
Again, thank you everyone for your input and patience!
Step One:
GET
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
Step Two: Parse the return for the following details
In the return, look for the column with the array in it and parse out the array. There are several columns of data needed from this array. Some of them are also outside of the array, but some are not. The array is called "api.fulfillment_orders line_items". The columns you need, depending on your requirements, are:
api.fulfillment_orders id = fulfillment_orders_id
api.fulfillment_orders assigned_location_id = location_id
api.fulfillment_orders order_id = order_id
api.fulfillment_orders line_items variant_id = variant_id
api.fulfillment_orders line_items id = line item identifier needed for your ship quantity array
Admittedly, there may have been something with the way I pulled in this data that caused the array to occur. So you may not have to parse out the data, but in case you do, those are the details. After that, put together an array with your shipping info (only if you need it).
{"id": {api.fulfillment_orders line_items id}, "quantity": {Quantity Shipped}}
Step Three: POST to API (or use your method of choice)
API: https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
JSON:
{
"fulfillment": {
"line_items_by_fulfillment_order": [{
"fulfillment_order_id": {api.fulfillment_orders id},
"fulfillment_order_line_items": [{Line Items Fulfillment Array}]
}],
"tracking_info": {
"company": "{Fulfillments: Tracking Company}",
"number": {Fulfillments: Tracking Number},
"url": "{Tracking URL}"
},
"notify_customer": false,
"location_id": {api.fulfillment_orders assigned_location_id}
}
}
Thank you so much for saving my day.
Its a big loss Shopify depreciated previous fulfilment api.
You are welcome. It took me around a week and 116 runs to finally figure the whole thing out. The array inside an array was the key to it all in the end. I had everything right but was using the wrong "level" of column references. I didn't want anyone else to go through what I went through.
Really happy this worked for you @hexonsoft!
For the life of me I can not get this to work in Postman. I have tried everything even the most basic. When I GET the fullfillment_orders.json I get a blank object "fulfillment_orders": []. And when Posting to fulfilments.json I get a 404.
I am able to fulfill the order with orders/{orderID}/fulfillments.json but it fulfills the whole order instead of single line items. Man this bugs.
Where am I going wrong?
https://xxx.myshopify.com/admin/api/2022-10/fulfillments.json
{
"fulfillment": {
"line_items_by_fulfillment_order": [
{
"fulfillment_order_id": {order id},
"fulfillment_order_line_items": [
{
"id": {line_items id},
"quantity": 1
}
]
}
],
"tracking_info": {
"company": "usps",
"number": 9470111298370372642929,
"url": "www.usps.com"
},
"notify_customer": false,
"location_id": {locationId}
}
}
Hi @submfg👋
Would you kindly check these requirements and review these steps to highlight exactly at which step you're running into errors?
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
getting error while using
https://xxx.myshopify.com/admin/api/2022-10/orders/{Order : Id}/fulfillment_orders.json
what should I do.
hello, I am following these steps but I always get "errors": "Not Found".
I am using version 2022-10