首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用C#将产品添加到Magento2RESTAPI中?

如何使用C#将产品添加到Magento2RESTAPI中?
EN

Stack Overflow用户
提问于 2018-02-05 09:06:43
回答 1查看 1.1K关注 0票数 0

如何使用c#以编程方式为Magento2.1创建新产品。每当我运行我的代码时,我都会得到这个异常,但我无法理解它的含义:

代码语言:javascript
复制
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))

这是什么意思?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-05 10:43:28

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

为什么要设置字段created_at和updated_at?这些都是由Magento自动填写,一旦您创建您的产品。

您应该打印出要发送的请求,并将结果JSON与rest调用这里的swagger列表进行比较

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48618949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档