Update item - Fabric

Update item

cURL

curl --request PATCH \
  --url https://api.fabric.inc/v3/carts/{cartId}/items/{itemId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
  --data '
{
  "refId": "41",
  "quantity": 2,
  "priceListId": "10001",
  "fulfillment": {
    "id": "6d65755f-b1d9-4c9d-bb5b-118d317f8db4",
    "inventory": {
      "type": "backOrder",
      "channels": {
        "networkCode": "ShipToHome"
      }
    }
  },
  "taxCode": "10001",
  "attributes": {
    "name": "item-custom"
  },
  "position": 1
}
'

Python Example

import requests

url = "https://api.fabric.inc/v3/carts/{cartId}/items/{itemId}"

payload = {
    "refId": "41",
    "quantity": 2,
    "priceListId": "10001",
    "fulfillment": {
        "id": "6d65755f-b1d9-4c9d-bb5b-118d317f8db4",
        "inventory": {
            "type": "backOrder",
            "channels": { "networkCode": "ShipToHome" }
        }
    },
    "taxCode": "10001",
    "attributes": { "name": "item-custom" },
    "position": 1
}
headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)

JavaScript (Fetch) Example

const options = {
  method: 'PATCH',
  headers: {
    'x-fabric-tenant-id': '<x-fabric-tenant-id>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    refId: '41',
    quantity: 2,
    priceListId: '10001',
    fulfillment: {
      id: '6d65755f-b1d9-4c9d-bb5b-118d317f8db4',
      inventory: {type: 'backOrder', channels: {networkCode: 'ShipToHome'}}
    },
    taxCode: '10001',
    attributes: {name: 'item-custom'},
    position: 1
  })
};

fetch('https://api.fabric.inc/v3/carts/{cartId}/items/{itemId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP Example

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.fabric.inc/v3/carts/{cartId}/items/{itemId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => json_encode([
    'refId' => '41',
    'quantity' => 2,
    'priceListId' => '10001',
    'fulfillment' => [
        'id' => '6d65755f-b1d9-4c9d-bb5b-118d317f8db4',
        'inventory' => [
                'type' => 'backOrder',
                'channels' => [
                                'networkCode' => 'ShipToHome'
                ]
        ]
    ],
    'taxCode' => '10001',
    'attributes' => [
        'name' => 'item-custom'
    ],
    'position' => 1
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json",
    "x-fabric-tenant-id: <x-fabric-tenant-id>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Response

Success Response (200)

{
  "id": "c86f777b-1885-4ddf-961d-542ba80a69b8",
  "attributes": {
    "name": "wishlist"
  },
  "configuration": {
    "order": {
      "validate": {}
    },
    "product": {
      "cacheExpiry": 7776000,
      "behaviors": {
        "add": "REJECT",
        "update": "WARN",
        "get": "WARN",
        "cacheExpiry": "WARN"
      },
      "maxQuantity": {
        "limit": 100,
        "behaviors": {
          "add": "REJECT",
          "update": "WARN",
          "get": "WARN"
        }
      }
    },
    "inventory": {
      "cacheExpiry": 7776000,
      "behaviors": {
        "add": "REJECT",
        "update": "WARN",
        "get": "WARN",
        "cacheExpiry": "WARN"
      },
      "check": "SKU"
    }
  }
}

Error Response Examples

  1. BAD_REQUEST (400)
   {
     "type": "BAD_REQUEST",
     "message": "x-fabric-tenant-id is required"
   }
  1. CART_NOT_FOUND (404)
   {
     "type": "CART_NOT_FOUND",
     "message": "Cart not found"
   }

Authorizations