如何使用 C# 将产品添加到 Magento 2 REST API?

How to Add a Product to Magento 2 REST API using C#?

如何使用 C# 以编程方式为 magento 2.1 创建新产品。 每当我 运行 我的代码时,我都会收到此异常,但我无法理解其含义:

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))

这是什么意思?

异常意味着您正在尝试设置产品中不存在的对象的 属性。

为什么要尝试设置字段 created_at 和 updated_at?一旦您创建产品,Magento 就会自动填充这些内容。

您应该打印出您正在发送的请求,并将生成的 JSON 与其余 api 调用 here

的 swagger 列表进行比较