/orders/{order_id}/fulfillments.json
/orders/{order_id}/fulfillments/{fulfillment_id}/complete.json
Just last week, I have been using these two apis to complete order fulfillment, but since last week, these two API calls return 404 not found.
The new version api tried to call to create a fulfillment:https:// shopify.dev/docs/api/admin-rest/2023-07/resources/fulfillment#post-fulfillments, of the parameters I found that fulfillment_order_id is required, but I don’t know got it.
angrow
July 11, 2023, 9:15am
2
I have the same question,Have you resolved the issue?
I didn’t solve this problem and I’m still trying to find an answer, if you have a way, I’d be more than happy to ask you, thank you
Hi, Angrow:
Today, I have resolved the issue and shared it with you.
Step1:Get fulfillment order id
Step2:Create fulfillment
Code:
def getFulfillmentOrdes(store_name, order_id):
fulfillment_orders = session.get(f'{const.auth_config.get(store_name).get("shopify_url_prefix")}orders/{order_id}/fulfillment_orders.json', auth=const.auth_config.get(store_name).get('shopify_auth'))
return json.loads(fulfillment_orders.text).get("fulfillment_orders")
def fulfillments_v2(store_name, order_id, tracking_number):
try:
fulfillment_orders = getFulfillmentOrdes(store_name, order_id)
if fulfillment_orders != None and len(fulfillment_orders) > 0:
fulfillment_order = fulfillment_orders[0]
line_items = fulfillment_order.get('line_items')
line_items_map = {}
line_items_map['fulfillment_order_id'] = fulfillment_order.get('id')
fulfillment_order_line_items = []
for line_item in line_items:
fulfillment_order_line_items.append({'id':line_item.get('id'), 'quantity':line_item.get('quantity')})
line_items_map['fulfillment_order_line_items'] = fulfillment_order_line_items
fulfillments_v2_params = {
"fulfillment": {
"line_items_by_fulfillment_order":[line_items_map],
"notify_customer":"true",
"tracking_info":{
"number":tracking_number,
"url":f"https://t.17track.net/en#nums={tracking_number}"
}
}
}
fulfill_result = session.post(f'{const.auth_config.get(store_name).get("shopify_url_prefix")}fulfillments.json', json.dumps(fulfillments_v2_params), auth=const.auth_config.get(store_name).get('shopify_auth'), headers=const.mock_headers)
print(f'fulfillment order result:{json.loads(fulfill_result.text)}')
except:
print(f'\033[1;31m {traceback.print_exc()} \033[0m')
print(f'\033[1;31m fulfillment have error, order_id:{order_id}, tracking_number:{tracking_number} \033[0m')