magentomagento2magento-rest-api

Magento 2 rest api doesn't update salable quantity


I use rest api to create a simple product on my magento. All works correctly except quantity column that is correctly update on "Quantity" column but not on the salable quantity.

Rest call: "www.mysite.com/V1/products"

Array data

$data = [
    "product" => [
        "sku" => $sku,
        "name" => $product_title,
        "attribute_set_id" => 4,
        "price" => $price,
        "status" => 1,
        "visibility" => 4,
        "type_id" => "simple",
        "weight" => "1",
        "extension_attributes" => [
            "category_links" => [
                [
                    "position" => 0,
                    "category_id" => "53"
                ]
            ],
            "stock_item" => [
                "qty" => $qty,
                "is_in_stock" => true
            ]
        ],
        "custom_attributes" => [
            [
                "attribute_code" => "special_price",
                "value" => $salable_price
            ],
            [
                "attribute_code" => "special_from_date",
                "value" => "2021-02-07 00:00:00"
            ],
            [
                "attribute_code" => "special_to_date",
                "value" => "2091-02-07 00:00:00"
            ],
            [
                "attribute_code" => "cost",
                "value" => $salable_price
            ],
            [
                "attribute_code" => "description",
                "value" => $description
            ],
            [
                "attribute_code" => "short_description",
                "value" => $short_description
            ]
        ]
    ]
];

As you see, qty has been correctly update on qty column but not on the salable quantity. What is my mistake?

enter image description here


Solution

  • Please try this:

    "stockItem": {
        "is_in_stock": 1,
        "qty": 10,
        "manage_stock": true,
        "use_config_manage_stock": 1
    }