2

Payload

{
  "product": {
    "sku": "samsung-a50",
    "name": "Samsung A50 ",
    "attribute_set_id": 4,
    "price": 150000,
    "status": 1,
    "visibility": 1,
    "type_id": "Default",
    "weight": "1",
    "extension_attributes": {
      "category_links": [
        {
          "position": 0,
          "category_id": "0"
        }
      ],
      "stock_item": {
        "qty": "10",
        "is_in_stock": true
      }
    },
    "custom_attributes": [
      {
        "attribute_code": "pattern",
        "value": "1960"
      },
      {
        "attribute_code": "color",
        "value": "45"
      },
      {
        "attribute_code": "size",
        "value": "168"
      }
    ]
  }
}

Error:

{
"message": "The \"Categories\" attribute value is empty. Set the attribute and try again.",
"trace": "#0 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\\Framework\\ObjectManager\\Factory\\AbstractFactory->createObject('Magento\\\\Eav\\\\Mod...', Array)\n#1 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\\Framework\\ObjectManager\\Factory\\Compiled->create('Magento\\\\Eav\\\\Mod...', Array)\n#2 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Validator/UniversalFactory.php(36): Magento\\Framework\\ObjectManager\\ObjectManager->create('Magento\\\\Eav\\\\Mod...', Array)\n#3 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(704): Magento\\Framework\\Validator\\UniversalFactory->create('Magento\\\\Eav\\\\Mod...', Array)\n#4 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-eav/Model/Entity/AbstractEntity.php(885): Magento\\Eav\\Model\\Entity\\AbstractEntity->walkAttributes('backend/validat...', Array, NULL)\n#5 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-catalog/Model/ResourceModel/Product.php(614): Magento\\Eav\\Model\\Entity\\AbstractEntity->validate(Object(Magento\\Catalog\\Model\\Product\\Interceptor))\n#6 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-catalog/Model/ProductRepository.php(555): Magento\\Catalog\\Model\\ResourceModel\\Product->validate(Object(Magento\\Catalog\\Model\\Product\\Interceptor))\n#7 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Catalog\\Model\\ProductRepository->save(Object(Magento\\Catalog\\Model\\Product\\Interceptor), false)\n#8 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Catalog\\Model\\ProductRepository\\Interceptor->___callParent('save', Array)\n#9 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Catalog\\Model\\ProductRepository\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Catalog\\Model\\Product\\Interceptor), false)\n#10 /var/www/vhosts/racoonracing.com/httpdocs/generated/code/Magento/Catalog/Model/ProductRepository/Interceptor.php(26): Magento\\Catalog\\Model\\ProductRepository\\Interceptor->___callPlugins('save', Array, Array)\n#11 [internal function]: Magento\\Catalog\\Model\\ProductRepository\\Interceptor->save(Object(Magento\\Catalog\\Model\\Product\\Interceptor), false)\n#12 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#13 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#14 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#15 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#16 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#17 /var/www/vhosts/racoonracing.com/httpdocs/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#18 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/App/Http.php(137): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#19 /var/www/vhosts/racoonracing.com/httpdocs/vendor/magento/framework/App/Bootstrap.php(261): Magento\\Framework\\App\\Http->launch()\n#20 /var/www/vhosts/racoonracing.com/httpdocs/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#21 {main}"

}

1

Give a try on the following payload

{
  "product": {
    "sku": "samsung-a50",
    "name": "Samsung A50 ",
    "attribute_set_id": 4,
    "price": 150000,
    "status": 1,
    "visibility": 1,
    "type_id": "simple",
    "weight": "1",
    "extension_attributes": {
      "category_links": [
        {
          "position": 0,
          "category_id": "2"
        }
      ],
      "stock_item": {
        "qty": "10",
        "is_in_stock": true
      }
    },
    "custom_attributes": [
      {
        "attribute_code": "pattern",
        "value": "1960"
      },
      {
        "attribute_code": "color",
        "value": "45"
      },
      {
        "attribute_code": "size",
        "value": "168"
      }
    ]
  }
}

"type_id": "simple" and "category_id": "2" should be greater or equal than 2 (2 is the of category id comes by default in case unless someone has changed).

Do not pass category_id as 0

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.