Create Fulfillment errors with status 406

Solved
Highlighted

I am trying to create Fulfillment for my order and the error on the response is status 406. Here is the request I am sending to Shopify

 

POST /admin/api/2019-07/orders/1706992140348/fulfillments.json
{
  "fulfillment": {
    "location_id": 1551256911932,
    "tracking_number": null,
    "notify_customer": true,
    "line_items": [
      {
        "id": 3792674029628
      }
    ]
  }
}

The response back from Shopify is as follows:

{
  "response": [
    
  ],
  "errors": {
    "status": 406,
    "body": null,
    "exception": [
      
    ]
  },
  "body": "",
  "timestamps": [
    null,
    1569968734.468354
  ]
}

Appreciate if someone could suggest what may be the issue with this API call

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes

Here is the request id information for the above request throwing an error

 

"X-Request-ID": [
    "f3a93e96-4fec-4e04-9426-a8815a552df1"
  ]

Appreciate if a Shopify Staff could help figure out the issue. @Jason@Josh  any ideas?

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes

Could any Shopify Staff look into this request and let me know what may be the issue?

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes

Success.

Shopify Staff
Shopify Staff
469 36 94

Hi @Greenlyst,

 

One thing I noticed quickly in your example you specify the URL as:

 

POST /admin/api/2019-07/orders/1706992140348/fulfillments.json

But your actual call is being sent to:

 

/admin/api/orders/1706992140348/fulfillments.json

 

which is invalid, you need to include the version if you are going to specifiy with /api/

 

/admin/orders/1706992140348/fulfillments.json

this would also work, and just serve the oldest stable version.

 

Hope that helps,

Ryan

 

 

Developer Experience @ Shopify
0 Likes

Hi @Ryan ,

 

Thanks for the reply. Not sure if I clearly understand what you mean.

 

The docs here https://help.shopify.com/en/api/reference/shipping-and-fulfillment/fulfillment?api[version]=2019-07#... under the section "Fulfill line items without a tracking number" indicates that I need to send the POST request to 

 

POST /admin/api/2019-07/orders/#{order_id}/fulfillments.json
{
  "fulfillment": {
    "location_id": 905684977,
    "tracking_number": null,
    "line_items": [
      {
        "id": 466157049
      },
      {
        "id": 518995019
      },
      {
        "id": 703073504
      }
    ]
  }
}

Am i missing something?

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes

Hey @Ryan ,

 

Thanks, I went back to the code and did some debugging and you were right that I was doing a POST request to a URL without the version. I did fix it, but not I seem to be getting a 404 error after fixing this and the request Id is "35281ed3-4339-4212-85e3-6e034df1cf69".

 

The peculiar thing is, the same request if I remove the "location_id" from the payload I pass on the request, it does give me the correct message that the location_id is missing on the request. Here is the request id for that "9dcdf22f-efb4-4745-a2d6-4834a9e1bf51", but adding the location_id back to the request gives the 404 error as mentioned above.

 

Am I still making a mistake. Could you please advice what may be the issue..

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
Shopify Staff
Shopify Staff
469 36 94

@Greenlyst 

 

Thanks for the reply, the most common cause of a 404 error when the majority of the request looks valid is an incorrect ID.  Shopify attempts to look up the ID provided for that shop and it doesn't exist.  In this case you are passing a location_id that does not exist on your shop.  The correct location_id to pass into the request is 33924120636, the ID of your fulfillment service "Greenlyst Fulfillment" that stocks the item in that order.

 

If you update to using the correct location, this should work.

 

Hope this helps,

Ryan

 

Developer Experience @ Shopify
0 Likes

Thank you very much for clarifying this.

 

I was using the "origin_location.id" property that I received on my order through the webhook (orders/create webhook -> "line_items.[0].origin_location.id").

 

The Order Id is 1706992140348. I was under the impression that the location id received is the same as the the location id of the fulfillment service as it is attached to the line item of the order. Could you please give me some information of what this object and its id means. It would help me understand this as well. But I will look into the id that I received when I created the fulfillment service.

 

I have attached below the object property that I used to set the location id.

Capto_Capture 2019-10-03_08-01-24_PM.png

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes

@Ryan ^^. Just mentioning here, not sure if you receive a notification if I just reply or if I have to mention you on the reply for it to work...

Abishek R Srikaanth | Co-Founder @ greenlyst.app
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
Shopify Staff
Shopify Staff
469 36 94

origin_location on an order is an undocumented parameter (generally don't recommend using these) that is used for tax purposes by Avalara. 

 

An order can contain a location_id parameter on it but is usually null.   This is only populated if the order was created from a Shopify POS location.

 

In Shopify, a location refers specifically to a physical location.  So if an order is created through the online store, it will not have a location_id.  However, fulfillment is a purely physical process, so to create a fulfillment, you need to specify which location it is coming from.  The location_id you pass into a fulfillments/create call must contain the ID of a location in Shopify that stocks the item you are trying to fulfill.  You can see these locations in the Admin or API https://greenlyst-test.myshopify.com/admin/locations.json or attached to the inventory_item.

 

We also have a more in depth guide on managing fulfillments at Shopify.  Just a note though, we are changing how fulfillments works slightly in an upcoming version (which you can already access on unstable) an a guide on that is also available, here.

 

Regards,

Ryan

 

Developer Experience @ Shopify
0 Likes