Add a Fulfillment for an Order via Admin API GraphQL

Add a Fulfillment for an Order via Admin API GraphQL

gavinharriss
Shopify Partner
7 1 1

I'm currently trying to add a fulfillment to an Order via the Admin GraphQL API but it's not clear how to accomplish this via the online documentation. I've probably just not found the correct docs yet.

 

I think I probably need to use fulfillmentCreateV2 but was originally setting fulfillmentOrderId to the order id:

gid://shopify/Order/4602774999999

 

The I found this answer that suggests I need to swap gid://shopify/Order/ to gid://shopify/FulfillmentOrder/ - but I'm not sure if this is correct as the API now reports an "INTERNAL_SERVER_ERROR".

 

I'm trying to add a fulfillment using the following request:

 

 

 

mutation {
  fulfillmentCreateV2(
    fulfillment: {
      lineItemsByFulfillmentOrder: [
        { fulfillmentOrderId: "gid://shopify/FulfillmentOrder/4602774999999" }
      ]
      trackingInfo: { company: "Test Courier Company", number: "TEST-123" }
    }
  ) {
    fulfillment {
      id
    }
    userErrors {
      field
      message
    }
  }
}

 

and this is the response I'm getting:

 

 

 

{
    "errors": [
        {
            "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 9cf21b83-0ae5-46e7-a8a7-723f50778d68 (include this in support requests).",
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR",
                "requestId": "9cf21b83-0ae5-46e7-a8a7-723f50778d68"
            }
        }
    ]
}

 

 
Any ideas what I may be doing wrong trying to add fulfillment information to an order?
Replies 2 (2)

KB77
Shopify Staff
59 6 11

Hi @gavinharriss , our logs for that request ID show an error that the FulfillmentOrder with ID 4602774913121 is not found. Are you sure that request ID was from the call example shown? It may be the case that the wrong ID is being used on the wrong store in this case. 

KB77 | API 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

gavinharriss
Shopify Partner
7 1 1

Thanks for getting back to me. I think the issue is that I've been trying to update an order with fulfilment information directly rather than through the fulfilment workflow? 

 

With other non-Shopify API's I'd search for orders to be handled and consume them directly, then once shipped I'd update an order directly. But now I've been scratching around in the docs and these forums I believe this is intentional prevented as Shopify is forcing fulfillment to be performed via a very specific workflow which I interpret something like this...

 

1) A one off job to register a FulfillmentService with the Shopify API for the 3rd party company, providing a bunch of API endpoints Shopify can use to notify us of orders.

 

2) Shopify receives an order and once a certain time has passed, allowing the customer an opportunity to cancel a placed order if they change their mind, it will then send a request to our API.

 

3) We then have to send a reply back to the Shopify API saying whether we accept the order or not. At this point we'll try to import the order and if it goes into CargoWise (the 3rd party system I'm plugging orders into) without issue we'll tell Shopify the order is accepted. If we encounter an error e.g. it includes a product CargoWise doesn't know about, we'll send a non-accepted reply so the shop staff can take action instead.

 

4) I believe accepting an order via this method will then add a FulfillmentOrder to the Order, which is what we'll update with the shipping details once fulfilled. This FulfillmentOrder is essential for updating a Shopify order with the shipping date and tracking information. There seems no other way through the API to add this needed FulfillmentOrder manually = Shopify forcing us to use its preferred workflow.

 

Have I interpreted things correctly? Or is there a simple method I can use to avoid the workflow as an initial quick win?