First thing I would like to share is that I am very new to magento. I am working on addition of products using rest api. I tried one product and it was created.

$headers = array('Authorization=> Bearer '. $token1); 


    //Use above token into header

    //Please note 24-MB01 is sku
    $ch = curl_init();
    $ch = curl_init($requestUrl); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
    curl_setopt($ch, CURLOPT_POST, true);
    $post ='{
      "product": {
        "sku": "MY_SKU11",
        "name": "My Product223",
        "attribute_set_id": "4",
        "price": 110,
        "status": 1,
        "visibility": 4,
        "typeId": "simple",
        "weight": 10,
        "extensionAttributes": {
          "stockItem": {
            "stockId": 1,
            "qty": 20,
            "isInStock": true,
            "isQtyDecimal": false,
            "useConfigMinQty": true,
            "minQty": 0,
            "useConfigMinSaleQty": 0,
            "minSaleQty": 0,
            "useConfigMaxSaleQty": true,
            "maxSaleQty": 0,
            "useConfigBackorders": false,
            "backorders": 0,
            "useConfigNotifyStockQty": true,
            "notifyStockQty": 20,
            "useConfigQtyIncrements": false,
            "qtyIncrements": 0,
            "useConfigEnableQtyInc": false,
            "enableQtyIncrements": false,
            "useConfigManageStock": true,
            "manageStock": true,
            "lowStockDate": "string",
            "isDecimalDivided": true,
            "stockStatusChangedAuto": 0,
            "extensionAttributes": {}
        "options": [],
        "tierPrices": [],
        "customAttributes": [
      "saveOptions": true

    $options = array(
        CURLOPT_USERAGENT=>"Mozilla/4.0 (compatible;)",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTPHEADER => array(
            "authorization: Bearer $token1",
            "content-type: application/json"

    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    $result=  json_decode($result);
    echo '</br>Response for add product<pre>';

The product is being created but when I am trying to update the same product and want to change price. I am unable to do so.

Can you guys help me out in this? Also is there any api documentation for this?



I'm pretty sure I had the same problem. Try and change the route to: /all/V1/products/{sku}

"all" applies to All Store views. Price and weight are global attributes and therefore not changed because /V1/products/{sku} only updates a store view.

I have not found any documentation on this topic...

| improve this answer | |

You should use PUT: /V1/products/{sku}.

For example:

$productData = [
    "sku" : "sku-test"
    "name": "Test",
    "price": 100,
    "status": 1

We can see more here: https://magento.stackexchange.com/a/151342/33057

| improve this answer | |
  • yes I am doing the same. Name, status and other things are updating but price and weight are not updating. – Md Jawed Shamshedi Mar 14 '17 at 14:21
  • I will check again! Which is your Magento version? – Khoa TruongDinh Mar 14 '17 at 14:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.