What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Unable to get a successful post for splitting fulfilments with REST APIs

Unable to get a successful post for splitting fulfilments with REST APIs

AndreSwart
Shopify Partner
3 0 2

I am using the REST API resources to integrate into a Shopify store. There is a rule that requires some Shopify orders to be split into multiple target resources, which in turn would need to fulfill the Shopify order partially once the split target order is marked as fulfilled. 

 

When retrieving the fulfillment order for this order, the supported_actions field state that it can be split, so the assumption is that we need to use the Fulfillment resource to action the partial fulfillment. One order can be fulfilled in full if I do not supply the "line_items_by_fulfillment_order" array of line items, however, when I provide the previously mentioned array with only the line items I want to fulfill, I get a 404. 

 

Endpoint used to GET fulfillment order:

/admin/api/2024-04/orders/{order_id}/fulfillment_orders.json

 

Endpoint used to POST the partial fulfillment: 

/admin/api/2024-04/fulfillments.json

 

Below is the body I use to post the partial fulfillment:

{
  "fulfillment": {
    "message": "Some Message here...",
    "notify_customer": false,
    "tracking_info": {
      "number": "123456789",
      "company": "Some courier company"
    },
    "line_items_by_fulfillment_order": [
      {
        "fulfillment_order_id": ID_from_Fulfillment_Order_resource,
        "fulfillment_order_line_items": [
          {
            "id": ID_from_Fulfillment_Order_Line_item_resource,
            "quantity": 1
          }
        ]
      }
    ]
  }
}

I am hoping to receive some clarity on how to split a fulfillment in Shopify using the REST resources. 

Replies 4 (4)

AndreSwart
Shopify Partner
3 0 2

I did more research on testing on this.

 

I used the payload structure of the fulfillment I was using to create the fulfillment in my current Shopify instance I am working with and changed the fulfillment_order_id to the ID of an order within a different Shopify instance and the POST went through with success. No changes were made to the structure, I just replaced the fulfillment_order_id. 

 

I compared the app permissions if the 2 instance's API users with each other and there are no differences, but still I am getting a 404 from Shopify when trying to POST a fulfillment. 

Kalen_Jordan
Shopify Partner
798 37 143

The fulfillment_order_id is different from the order ID. You'll want to pass in the fulfullment_order_id you get back from /admin/api/2024-04/orders/{order_id}/fulfillment_orders.json

AndreSwart
Shopify Partner
3 0 2

Hi Kalen, 

 

Yes, this is what I am doing.

 

I have done more research and testing and it seems that there is an issue with the store's hostname. We can make successful GET request to the named store address (store_name.myshopify.com), however when we try to POST to the named address, we are getting a 301 returned by the initial POST (The one I initiated). Directly after this POST request, a GET is executed automatically to the fulfillments endpoint that returns a 404, but it the address is a weird string of letters and numbers that was randomly assigned. 

 

I have done a couple of Shopify integrations via the REST APIs and have never experienced this. This is definitely something Shopify support needs to address within the set up of this store instance. 

Kalen_Jordan
Shopify Partner
798 37 143

Ah gotcha. Super weird!