9

Using Magento 2.2.2, I was trying to add stock updates to a pre-existing setup using the official defined endpoint:

rest/V1/products/testsku/stockItems/1

with

{ 
  "stock_item": {
    "qty": 1234,
    "is_in_stock": true
  }
}

which wouldn't work. Searching around, I found an example here which essentially strips the product create/update JSON right back to the bare minimum and just include the stock data:

rest/V1/products/testsku

.

{
  "product": {
    "sku": "testsku",
    "extensionattributes": {
      "stockitem": {
        "qty": 1234,
        "isinstock": true,
      }
    }
  },
 "saveOptions": true
}

I changed my stock update process to call this instead, and it works.

However, I noticed afterwards that the extensionattributes (and it's sub fields) is missing the underscore, according to the official swagger API documentation. My product create call already includes the underscore fields when creating the item to set an initial stock quantity, yet don't seem to be working.

What's the difference - underscore or no underscore? Which is correct? Is this a bug or an undocumented change, or are both field names valid?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.