Hey everyone, It has been two weeks since I am trying to fulfill orders using Python API.
I have all the scopes mentioned by Shopify to fulfill the order.
I did a lot of research in the past two weeks and tried a lot of different codes but still had no luck with any of them.
Can someone please help me to get out of this hell, it has been so annoying now.
I am sharing the code that I am using right now.
new_orders = shopify.Order.find()
for order in new_orders:
fo = shopify.FulfillmentOrders.find(order_id=order.id)[0]
location = fo.assigned_location_id
fulfillable_quantity = fo.line_items[0].fulfillable_quantity
fulfillment = shopify.Fulfillment({
'order_id':fo.order_id,
})
fulfillment.location_id = location
fulfillment.notify_customer = True
fulfillment.message = 'The package has been shipped this morning'
fulfillment.tracking_info = {
"number": "11111111",
"url": "https://mysite.myshopify.com",
"company": "USPS"
};
fulfillment.line_items_by_fulfillment_order = [
{
"fulfillment_order_id": fo.id,
"fulfillment_order_line_items": [
{
"id": fo.line_items[0].id,
"quantity": fulfillable_quantity
}
]
}
]
fulfillment.save()
The error that I am getting is for Resource.
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/pyactiveresource/connection.py in _open(self, method, path, headers, data)
285 try:
--> 286 http_response = self._handle_error(self._urlopen(request))
287 except urllib.error.HTTPError as err:
12 frames
HTTPError: HTTP Error 404: Not Found
During handling of the above exception, another exception occurred:
ResourceNotFound Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/pyactiveresource/connection.py in _handle_error(self, err)
417 raise ForbiddenAccess(err)
418 elif err.code == 404:
--> 419 raise ResourceNotFound(err)
420 elif err.code == 405:
421 raise MethodNotAllowed(err)
ResourceNotFound: Not Found: https://abc.myshopify.com/admin/api/2023-04/orders/5357871431987/fulfillments.json