0

I am using endpoint /V1/products to create product.

Request body:

{ 
   "product":{ 
      "id":0,
      "sku":"jitterjitter",
      "name":"jitterjitter",
      "attribute_set_id":4,
      "price":45,
      "type_id":"simple",
      "weight":1,
      "extension_attributes":{
         "stock_item":{ 
            "item_id":123,
            "product_id":3435,
            "qty":5,
            "is_in_stock":true,
            "is_qty_decimal":true,
            "show_default_notification_message":true,
            "use_config_min_qty":true,
            "min_qty":0,
            "use_config_min_sale_qty":0,
            "min_sale_qty":0,
            "use_config_max_sale_qty":true,
            "max_sale_qty":0,
            "use_config_backorders":true,
            "backorders":0,
            "use_config_notify_stock_qty":true,
            "notify_stock_qty":0,
            "use_config_qty_increments":true,
            "qty_increments":0,
            "use_config_enable_qty_inc":true,
            "enable_qty_increments":true,
            "use_config_manage_stock":true,
            "manage_stock":true,
            "low_stock_date":"string",
            "is_decimal_divided":true,
            "stock_status_changed_auto":0,
            "extension_attributes":{ 

            }
         }
      }
   },
   "saveOptions":true
}

and the response I am getting is:

    {
    "message": "Property \"ShowDefaultNotificationMessage\" does not have corresponding setter in class \"Magento\\CatalogInventory\\Api\\Data\\StockItemInterface\".",
    "trace": "#0 /home/jitterbi/public_html/magento2/vendor/magento/framework/Reflection/NameFinder.php(74): Magento\\Framework\\Reflection\\NameFinder->findAccessorMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), 'ShowDefaultNoti...', 'setShowDefaultN...', 'setIsShowDefaul...')\n#1 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(163): Magento\\Framework\\Reflection\\NameFinder->getSetterMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), 'ShowDefaultNoti...')\n#2 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(322): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('\\\\Magento\\\\Catalo...', Array)\n#3 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(175): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, '\\\\Magento\\\\Catalo...')\n#4 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(322): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('\\\\Magento\\\\Catalo...', Array)\n#5 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(175): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, '\\\\Magento\\\\Catalo...')\n#6 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(322): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Catalog...', Array)\n#7 /home/jitterbi/public_html/magento2/vendor/magento/framework/Webapi/ServiceInputProcessor.php(119): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, 'Magento\\\\Catalog...')\n#8 /home/jitterbi/public_html/magento2/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Catalog...', 'save', Array)\n#9 /home/jitterbi/public_html/magento2/vendor/magento/module-webapi/Controller/Rest.php(299): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n#10 /home/jitterbi/public_html/magento2/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#11 /home/jitterbi/public_html/magento2/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(37): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#12 /home/jitterbi/public_html/magento2/vendor/magento/framework/App/Http.php(136): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#13 /home/jitterbi/public_html/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#14 /home/jitterbi/public_html/magento2/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#15 {main}"
}

Why endpoint is accepting this value "show_default_notification_message":true.So I removed this particular field to check if request body is correct or not. So after removing this field, it works fine.

Successfull 200 Response after removing "show_default_notification_message":true field.

{
    "id": 85378,
    "sku": "jitterjitter123",
    "name": "jitterjitter123",
    "attribute_set_id": 4,
    "price": 45,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2019-11-22 10:25:23",
    "updated_at": "2019-11-22 10:25:23",
    "weight": 1,
    "extension_attributes": {
        "stock_item": {
            "product_id": 0,
            "stock_id": 1,
            "qty": null,
            "is_in_stock": true,
            "is_qty_decimal": false,
            "show_default_notification_message": false,
            "use_config_min_qty": false,
            "min_qty": 0,
            "use_config_min_sale_qty": 0,
            "min_sale_qty": 0,
            "use_config_max_sale_qty": false,
            "max_sale_qty": 0,
            "use_config_backorders": false,
            "backorders": 0,
            "use_config_notify_stock_qty": false,
            "notify_stock_qty": 0,
            "use_config_qty_increments": false,
            "qty_increments": 0,
            "use_config_enable_qty_inc": false,
            "enable_qty_increments": false,
            "use_config_manage_stock": false,
            "manage_stock": false,
            "low_stock_date": null,
            "is_decimal_divided": false,
            "stock_status_changed_auto": 0
        }
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "category_ids",
            "value": []
        },
        {
            "attribute_code": "options_container",
            "value": "container2"
        },
        {
            "attribute_code": "required_options",
            "value": "0"
        },
        {
            "attribute_code": "has_options",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "jitterjitter123"
        },
        {
            "attribute_code": "tax_class_id",
            "value": "2"
        }
    ]
}

Please guide if I am doing something wrong, I am unable to understand that why Magento endpoint is not throwing 500 error with this boolean type field ?

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.