0

How to create a new product to magento 2.1 programmatically using c#. Whenever I run my code I get this exception but I cannot understand the meaning:

main.CRITICAL: LogicException: 
    Property "0" does not have corresponding setter in class "Magento\Catalog\Api\Data\ProductInterface". in C:\wamp64\www\Magento\vendor\magento\framework\Reflection\NameFinder.php:100
    Stack trace:

#0 C:\wamp64\www\Magento\vendor\magento\framework\Reflection\NameFinder.php(59): Magento\Framework\Reflection\NameFinder->findAccessorMethodName(Object(Zend\Code\Reflection\ClassReflection), '0', 'get0', 'is0')

#1 C:\wamp64\www\Magento\vendor\magento\framework\Webapi\ServiceInputProcessor.php(158): Magento\Framework\Reflection\NameFinder->getGetterMethodName(Object(Zend\Code\Reflection\ClassReflection), '0')

#2 C:\wamp64\www\Magento\vendor\magento\framework\Webapi\ServiceInputProcessor.php(322): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('Magento\\Catalog...', Array)

#3 C:\wamp64\www\Magento\vendor\magento\framework\Webapi\ServiceInputProcessor.php(119): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, 'Magento\\Catalog...')

#4 C:\wamp64\www\Magento\vendor\magento\module-webapi\Controller\Rest\InputParamsResolver.php(101): Magento\Framework\Webapi\ServiceInputProcessor->process('Magento\\Catalog...', 'save', Array)

#5 C:\wamp64\www\Magento\vendor\magento\module-webapi\Controller\Rest.php(299): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()

#6 C:\wamp64\www\Magento\vendor\magento\module-webapi\Controller\Rest.php(216): Magento\Webapi\Controller\Rest->processApiRequest()

#7 C:\wamp64\www\Magento\var\generation\Magento\Webapi\Controller\Rest\Interceptor.php(37): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))

#8 C:\wamp64\www\Magento\vendor\magento\framework\App\Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

#9 C:\wamp64\www\Magento\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#10 C:\wamp64\www\Magento\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

What does this mean?

sissy
  • 2,908
  • 2
  • 28
  • 54

1 Answers1

0

The exception means that you're trying to set a property of the object that does not exist in the product.

why are you trying to set the fields created_at and updated_at? These are automatically filled by Magento as soon as you create your product.

You should print out the request you're sending and compare the resulting JSON with the swagger list of rest api calls here

sissy
  • 2,908
  • 2
  • 28
  • 54