Magento – REST API Update Product HTTP Method PUT or POST

apimagento2rest

The REST API documentation says that PUT /V1/products/{sku} creates rather than updates.

Is that an error in the docs because I would have assumed that it is an update method and POST being the method to create?

Best Answer

POST and PUT route to same method save, but with POST you cannot pass sku

  <route url="/V1/products" method="POST">
        <service class="Magento\Catalog\Api\ProductRepositoryInterface" method="save"/>
        <resources>
            <resource ref="Magento_Catalog::products" />
        </resources>
    </route>
    <route url="/V1/products/:sku" method="PUT">
        <service class="Magento\Catalog\Api\ProductRepositoryInterface" method="save" />
        <resources>
            <resource ref="Magento_Catalog::products" />
        </resources>
    </route>
Related Topic