Development discussions around Shopify APIs
I'm trying to fulfill a line item on an order with the python API but I'm getting an error. I'm trying to do this:
xxxx is the line_item ID and yyyy is the order_id
line_items =[{"id": xxxx}]
new_fulfillment = shopify.Fulfillment()
new_fulfillment.order_id = "yyyy"
new_fulfillment.line_items = line_items
new_fulfillment.save()
However at this point I get an error
pyactiveresource.connection.ResourceNotFound: Not Found: https://postrgram.myshopify.com/admin/orders//fulfillments.json
It looks like the order_id is not getting into the endpoint URL correctly. What am I missing here?
Hi Arian,
The following should work:
order = shopify.Order.find(XXXXXX) new_fulfillment = shopify.Fulfillment({'order_id': order.id, 'line_items': order.line_items}) new_fulfillment.save()
Note that you are passing in the line_items themselves, and not their IDs.
Good luck!
Hammad
Update in 2021, location_id is mandatory for the fulfillment. This is my sample code to do it
order = shopify.Order.find(1234567890)
location = shopify.Location.find()[0]
new_fulfillment = shopify.Fulfillment({'order_id': order.id,
'line_items': order.line_items,
'location_id': location.id})
new_fulfillment.save()
User | RANK |
---|---|
48 | |
11 | |
5 | |
5 | |
5 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023