1
votes

I am trying to create a new fulfillment for an order using the Shopify API. Here's a sample XML request that I’m sending:

<?xml version="1.0" encoding="UTF-8"?>
<fulfillment>
    <tracking-number>1Z0000000300002879</tracking-number>
    <notify-customer type="boolean">false</notify-customer>
</fulfillment>

I get a 200-OK after POST /admin/orders/12345678/fulfillments.xml. The order gets updated to fulfilled correctly, however the tracking number field is still blank. This happens for every order I update; the status is fulfilled but the tracking number is never set. Ideas?

2
You should be getting a 201 Created response if you're creating a new fulfillment correctly. Can you post the actual ids you're using along with your API key? That will help us debug the issue. Thanks! - David Underwood

2 Answers

1
votes

The {"line_items" => ["order_item_id1", "order_item_id2", "order_item_id3"],

is different than the API documentation which says the line_items are line_item objects not just strings of the order item id.

"fulfillments": [
{
  "created_at": "2012-09-28T11:50:06-04:00",
  "id": 255858046,
  "order_id": 450789469,
  "service": "manual",
  "status": "failure",
  "tracking_company": null,
  "tracking_number": "1Z2345",
  "tracking_url": "http://www.google.com/search?q=1Z2345",
  "updated_at": "2012-09-28T11:50:06-04:00",
  "receipt": {
    "testcase": true,
    "authorization": "123456"
  },
  "line_items": [
    {
      "fulfillment_service": "manual",
      "fulfillment_status": null,
      "grams": 200,
      "id": 466157049,

I'm trying the latter but have to wait until another order comes in because I get 'Unprocessable Entity' for a duplicate fulfillment.

Not sending any line_items causes the tracking number to be ignored but the order fulfilled.

-1
votes

The fulfillment expects a list of line_items that should be marked fulfilled with that tracking number. You aren't sending any, so none can be marked fulfilled.

Here's a rails example I've got on hand that should get you in the right direction.

@payload = {"fulfillment" =>
    {"line_items" => ["order_item_id1", "order_item_id2", "order_item_id3"],
    "notify_customer" => true,
    "tracking_number" => order.tracking_number
    }}.to_json