Unable to Mark Orders Fulfilled Via API Call

otirenmedia
New Member
4 0 0

I sell digital service (no actual tracking number needed) and I'm using a custom script that needs to fulfill orders (mark as fulfilled) via POST API call. The error I get is

"The fulfillment order's assigned fulfillment service must be of api type" 

 I have all read and write settings for the API settings. I have looked for this question on the community and the relevant answers did not resolve my issues (creating custom fulfillment service from shipping settings, read&write access, tried to install a self-created developer app, but the link was broken).

I think if I can get my app installed on my store I might be able to set the fulfillment service to api type, but I can't even get it installed. All I want to do is to be able to mark my order as fulfilled via an API call. Any help is greatly appreciated. 

Replies 8 (8)

HunkyBill
Shopify Expert
4846 60 552

You really need to provide more details, as fulfillment is one of the more complex issues to master. Some basic info you could provide:

  • What were the relevant line item attributes for fulfillment?
  • What data did you use to make that fulfillment that was rejected?

There are hundred ways or more to screw up. To dig in, you need to expose all the gory details. What was the fulfillment service at the time the order was booked? What API call did you make? And it goes on and on.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
otirenmedia
New Member
4 0 0

Sure so here is a request that gives me this error. I'm using python

d = requests.post("https://[API Auth]@[My Store].myshopify.com/admin/api/2020-10/fulfillment_orders/4171163173053/fulfillment_request.json",json={'fulfillment_request':{"locataion_id":56540266685,'fulfillment_order_line_items':[{'id':7582317674685,'quantity':50}]}})
print(d.text)

{"errors":["The fulfillment order's assigned fulfillment service must be of api type"]}

 The actual attributes of the line item shouldn't be that important I would imagine. Maybe I'm wrong, but there are no variants and, since it is not a physical product, there is no shipping involved. The only attributes that a line item could reasonably use (at least in my mind) are product type and url (a custom item attribute i need to perform the service) since those are the only things that can be different between the line items within one order

The fulfillment service at the time was shopify. I had not yet made a custom fulfillment service, but even after I did, and switched the fulfillment in the order menu, I was still unable to fulfill (same error). That led me to thinking that maybe I need to create an app and install it to my store for me to actually set the fulfillment to type API as the error says, but I am unable to install an app for some reason. 

Does this help clarify at all?

HunkyBill
Shopify Expert
4846 60 552

You claim it does not matter, but it does matter. When Shopify books an order for you, it consists of one or more line items. If you examine a line item, you will see attributes that deal with inventory and fulfillment. You cannot gloss over those. You should list what they were at the time the order was booked. It does make a difference because Shopify will create FulfillmentOrder objects based on these settings. In your case, for some reason, your object is not so easily marked as fulfillable, probably because you forgot something, but we cannot see that yet, as you have not provided either the product setup data (product setup), nor the order processed data (line item settings).

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
otirenmedia
New Member
4 0 0

I have not claimed it does not matter. Rather, I explained why they seemed like they would not be important so as to better help you understand my current understanding of the system. Here is the json data I get when performing a GET request against my Store for the order I am trying to fulfill.  Please Let me know if this has the line item attributes you are talking about. It would help me a lot if you could explain what/where these attributes are/do instead of simply telling me they are important. I very much appreciate the effort

 

GET ... admin/api/2020-10/orders/2948732682429/fulfillment_orders.json"

{"fulfillment_orders":
[{"id":4171163173053,"shop_id":ShopID,"order_id":2948732682429,"assigned_location_id":MY_LOCATIONID,"fulfillment_service_handle":"manual","request_status":"unsubmitted","status":"open",
"supported_actions":["create_fulfillment"],"destination":null,
"line_items":
[{"id":7582317641917,"shop_id":ShopID,"fulfillment_order_id":4171163173053,"quantity":50,"line_item_id":8775204929725,"inventory_item_id":39033420251325,
"fulfillable_quantity":50,"variant_id":36940630524093},
{"id":7582317674685,"shop_id":ShopID,"fulfillment_order_id":4171163173053,"quantity":50,"line_item_id":8775204962493,"inventory_item_id":39033419432125,
"fulfillable_quantity":50,"variant_id":36940629999805}],
"assigned_location":{"address1":"MY Address","address2":"","city":"MY City","country_code":"US","location_id":MY_LOCATIONID,"name":"MY Address Name","phone":"##########","province":"MY State","zip":"My Zip"},"merchant_requests":[]}]}


syf_
Shopify Staff
95 21 24

 

Hey @otirenmedia,

I'll be happy to throw some more light on the error you're encountering. Essentially, creating FulfillmentRequest is responsible for sending a request to a third-party warehouse telling them to handle a fulfillment order. Check out this forum post  for details on why you are seeing this error - {"errors":["The fulfillment order's assigned fulfillment service must be of api type"]}.

Since you mention you sell a digital service, you wouldn't need to be making this call to mark an order as being fulfilled. To mark an order as fulfilled, you would have to make a POST request as shown here from the docs. This would create a fulfillment and mark its status as success; if I understand correctly, that is what you're looking to achieve.

Hopefully this clarifies the error you're receiving, and you can now mark orders as fulfilled using the API.

Let me know if you are still unable to mark an order as being fulfilled and I'd be happy to help out. Thank you!

 

Best,

Seth.

syf_ | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

nayantaraSingh
Shopify Partner
7 0 0

hey @otirenmedia , I am facing the same issue as you mentioned above.
I am also using python. And I want to mark particular vendor item in order to fulfilled using API call.
Will it be possible to it without creating any fulfillment service app.

Please help !!




 

folz-14
Shopify Partner
3 0 0

Yes this is possible. You will have to fulfill the item(s) using the '/admin/api/2023-01/fulfillments.json' endpoint. You can read more about it here - Create a Fulfillment.

Note that the "fulfillment_order_id" is not the order id but the FulfillmentOrder id which can be gotten from Get Fulfillment_orders endpoint.

 

I haven't done this with pyton though it should be similar to php. I use the phpclassic package and below is a working example (assuming you already have the authentication and $order objects.

 

 

if ($order['id']){
	//Get FulfillmentOrder
	$FulfillmentOrders = $shopify->Order($order['id'])->FulfillmentOrder()->get();
	if(!empty($FulfillmentOrders)){
		foreach($FulfillmentOrders as $FulfillmentOrder){
			foreach($FulfillmentOrder['line_items'] as $item){
				//Fulfill only items not yet fulfilled
				if($item['fulfillable_quantity'] > 0){
					try{
						$data = array(
							'location_id' => $item['assigned_location_id'],
							'tracking_number' => null,
							'notify_customer' => false,
							'line_items_by_fulfillment_order' => [
								array(
									'fulfillment_order_id' => $item['fulfillment_order_id'],
									'fulfillment_order_line_items' => [
										array(
											'id' => $item['id'],
											'quantity' => $item['quantity']
										)
									]
								)
							]
						);
						$Fulfillment = $shopify->Fulfillment->post($data);
					} catch(Exception $e) {
						echo 'Caught exception - Fulfillment Items: ' . $order['id'] . ' - ',  $e->getMessage(), "\n";
						continue;
					}
				}
			}
		}
	}
}

 

 

Hope it helps. 

antonmo
Visitor
1 0 0

When you get this error when creating a fulfillment, query the fulfillment order and check the assigned location. The assigned location must be the location of the fulfillment service app you are using to create the fulfillment.