Order creation API responds with 422 when setting inventory_behaviour to decrement_obeying_policy

Solved
yashafromrussia
New Member
2 1 0

I'm using Admin API to create an order on a store. However, using this specific store, when setting inventory_behaviour to decrement_obeying_policy or bypass explicitly, it returns a "422 (Unprocessable Entity)" error.

 

I tried using 2020-01 and 2020-10 API versions & reproduced the same behaviour on both. The following order input is used (using shopify-api-node, which already injects this into {"order": {}}

 

{
  source_name: 'web',
  email: 'test@gmail.com',
  financial_status: 'paid',
  token: '5fdad357fd87ff003ee83597',
  customer: { first_name: 'Test', email: 'test@gmail.com', last_name: 'Test' },
  fulfillment_status: null,
  shipping_address: {
    address1: '1600 Pennsylvania Avenue NW',
    address2: '3j',
    city: 'Washington',
    country: 'US',
    name: 'Test',
    phone: '(720) 231-1611',
    province: 'DC',
    zip: '20500',
    first_name: 'Jim',
    last_name: 'Test'
  },
  shipping_lines: [
    {
      title: 'US Flat Rate Shipping & duties',
      code: '0',
      price: '0.00',
      source: 'Merchant provided flat rate shipping'
    }
  ],
  line_items: [
    {
      product_id: '4750502723655',
      variant_id: '32450939813959',
      title: 'Title',
      name: 'Name',
      quantity: 1,
      requires_shipping: true,
      price: 165
    }
  ],
  total_tax: '0.00',
  tax_lines: [ { price: 0, title: 'total taxes', rate: 0 } ],
  discount_codes: [ { amount: 33, type: 'fixed_amount', code: 'Application Fee' } ],
  inventory_behaviour: 'decrement_obeying_policy',
  test: true,
  send_receipt: true,
  send_fulfillment_receipt: true
}

 

 If inventory_behaviour is set to decrement_ignoring_policy or removed, then the order is created successfully. This is strange since running this API request against other stores works just fine.

 

The request ID is 695c1b8e-7276-4c6f-942f-4e0eafc9cd1f. Could someone from the Shopify team please help in investigating the issue with using inventory_behaviour?

0 Likes
yashafromrussia
New Member
2 1 0

This is an accepted solution.

Shopify Admin API responds with the 422 error when the item is out of stock & inventory_behaviour is explicitly set to either decrement_obeying_policy or bypass

0 Likes