fulfill an order via the graphql API with Shopify 2020-01 ?

ong
Tourist
3 0 1

Hi @all,

I want to fulfill an orders via the graphQL API.

I have been looking at the fulfillmentCreate mutation. I see the doc for that and run the following graphQL request and it's working fine.  

 

mutation fulfillmentCreate($input: FulfillmentInput!) {
  fulfillmentCreate(input: $input) {
    fulfillment {
      id
    }
    order {
      id
    }
    userErrors {
      field
      message
    }
  }
}
{
  "input": {
    "orderId": "2215630864456",
    "locationId": "4840180613192"
  }
}

 

But as per Shopify docs, fulfillmentCreate mutation is deprecated and  fulfillmentCreateV2 mutation is introduced for order fulfillment. 
and I had tried with new order fulfillment with the latest fulfillmentCreateV2 with the below request I got an error from Shopify. 

 

mutation {
  fulfillmentCreateV2(fulfillment: {
    notifyCustomer: true
    trackingInfo: {
      number: "123456789",
      company: "USPS",
      url: "http://www.google.com"
    }
    lineItemsByFulfillmentOrder: {
      fulfillmentOrderId: "gid://shopify/FulfillmentOrder/2215630864456",
      fulfillmentOrderLineItems: [
        {
          id: "gid://shopify/LineItem/4840180613192",
          quantity: 1,
        }
      ]
    }
  }) {
    fulfillment {
      trackingInfo {
        url
        number
        company
      }
    }
  }
}

and I got the error from Shopify

{
  "errors": [
    {
      "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: a5d03da1-0acb-4ac5-8e60-64197587e452 (include this in support requests).",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "requestId": "a5d03da1-0acb-4ac5-8e60-64197587e452"
      }
    }
  ]
}

Can you please suggest to me what is going wrong in the latest order fulfillment module. 
References:- 
https://shopify.dev/docs/admin-api/graphql/reference/mutation/deprecated/fulfillmentcreate
https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources

Thanks,
-ONG

 

 

mellon_collie
Shopify Partner
12 0 2

I have another issue related to GraphQL orders API with INTERNAL_SERVER_ERROR

https://community.shopify.com/c/Shopify-APIs-SDKs/GraphQL-API-orders-request-error/m-p/717324

But it refers to data import.

Maybe those issues related to each other?

0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 134

Hi @ong ,

 

The reason why you are getting an error for this fulfillmentCreateV2 mutation is being the value you are using for the "fulfillmentOrderLineItems.id" input is incorrect.

 

In your mutation, you set the value for this input as "gid://shopify/LineItem/4840180613192" - this is incorrect. Instead the value you should enter instead for this input is the FulfillmentOrderLineItem ID within this FulfillmentOrder. This ID looks something like this "gid://shopify/FulfillmentOrderLineItem/{unique-ID-value}". You can get the FulfillmentOrderLineItem ID from querying the FulfillmentOrder, with this GraphQL query:

 

query {
  fulfillmentOrder(id:"gid://shopify/FulfillmentOrder/1754040434710") {
    lineItems (first:20) {
      edges {
        node {
          id
          remainingQuantity
          totalQuantity
        }
      }
    }
  }
}

Once you use the correct value of the "fulfillmentOrderLineItems.id" input value, you should no longer be getting these errors and your fulfillment should be successfully created

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
ong
Tourist
3 0 1

@hassain wrote:

Hi @ong ,

 

The reason why you are getting an error for this fulfillmentCreateV2 mutation is being the value you are using for the "fulfillmentOrderLineItems.id" input is incorrect.

 

In your mutation, you set the value for this input as "gid://shopify/LineItem/4840180613192" - this is incorrect. Instead the value you should enter instead for this input is the FulfillmentOrderLineItem ID within this FulfillmentOrder. This ID looks something like this "gid://shopify/FulfillmentOrderLineItem/{unique-ID-value}". You can get the FulfillmentOrderLineItem ID from querying the FulfillmentOrder, with this GraphQL query:

 

query {
  fulfillmentOrder(id:"gid://shopify/FulfillmentOrder/1754040434710") {
    lineItems (first:20) {
      edges {
        node {
          id
          remainingQuantity
          totalQuantity
        }
      }
    }
  }
}

Once you use the correct value of the "fulfillmentOrderLineItems.id" input value, you should no longer be getting these errors and your fulfillment should be successfully created



Hi hassain ,
Thanks for the reply for my recent query, So I have tried with your given solution by the problems remains same.
I have to ask some other queries along with that issue which is,


Suppose you have an order and want to fulfillment that order with graphql api request in shopify.
(Note:- You have latest order and not fulfill or partial fulfill that order in past.)

1. So what is the mutation to fulfill that order with graphql ?
2. is fulfillment order id and shopify order id is same or different ?
3. If answer of point 2 is different then how do you got fulfillment order id ?

 

0 Likes
ong
Tourist
3 0 1

@mellon_collie wrote:

I have another issue related to GraphQL orders API with INTERNAL_SERVER_ERROR

https://community.shopify.com/c/Shopify-APIs-SDKs/GraphQL-API-orders-request-error/m-p/717324

But it refers to data import.

Maybe those issues related to each other?


Yeah when we are using GraphQL, Shopify doesn't reported with original error message.
They need to send real messages with api request like rest api requests for better development approaches.

0 Likes
hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 134

Hi @ong ,

 

This document will answer all three questions for you: https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
WarwickBrown
New Member
2 0 0

Hi Hassain,

 

That doesn't answer the whole thing.

 

I'm trying to migrate from REST to GraphQL. I have an order which is paid and not fulfilled.

 

I execute the following query:

query {
  order(id:"gid://shopify/Order/2369239515198") {
    id,
    displayFinancialStatus,
    displayFulfillmentStatus,
    fulfillmentOrders(first:10) {
      edges {
        cursor,
        node {
          id,
          status
        }
      }
    },
    fulfillments {
      id
    }
  }
}

Which returns the following response:

 

{
  "data": {
    "order": {
      "id": "gid://shopify/Order/2369239515198",
      "displayFinancialStatus": "PAID",
      "displayFulfillmentStatus": "UNFULFILLED",
      "fulfillmentOrders": {
        "edges": []
      },
      "fulfillments": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 14,
      "actualQueryCost": 4,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 996,
        "restoreRate": 50
      }
    }
  }
}

Note, fulfillmentOrders is empty.

 

I want to create a fulfillment to mark the order as shipped and provide the customer with a tracking URL. Currently I'm able to easily do this with REST, but I cannot understand why I don't have any fulfillment orders displaying against the order.

 

I am not using a fulfillment service, all orders flow in to our ERP via an interface with the Shopify API, and then tracking data flows back out once the order has shipped. We treat Shopify orders the same as everything else.

 

I cannot find in this document you have provided how I am meant to create a fulfillmentOrder to then use to create a fulfillment,

0 Likes
WarwickBrown
New Member
2 0 0

Okay, I worked out that I needed to turn on access to Merchant-managed fulfillment orders in the app config in admin.

 

It would be very helpful if the API returned an access error instead of just an empty array, then I would have been able to work this out in seconds.

 

 

Screen Shot 2020-05-31 at 8.53.55 pm.png

0 Likes
Avonis
New Member
3 0 0

Hi @ong 
How do you get the fullfillemnt order , once order is created or afterword?

0 Likes