Greetings,
i am trying to add a product via api and json.
The error occurs when the image is added.
Here is the code snippet I use:
{
"entry": {
"media_type": "image",
"label": "Image",
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"file": "string",
"content": {
"base64_encoded_data": "/9j/4AAQSkZJRgABAQEAYABgAAD/4QBk=.......................",
"type": "image/jpeg",
"name": "new_image2.jpeg"
}
}
}This is the error output from postman:
{"message":"Property \"Entry\" does not have accessor method \"getEntry\" in class \"Magento\\Catalog\\Api\\Data\\ProductAttributeMediaGalleryEntryInterface\".","trace":"
#0 \/home\/test\/test.it\/vendor\/magento\/framework\/Reflection\/NameFinder.php(59): Magento\\Framework\\Reflection\\NameFinder->findAccessorMethodName(Object(Laminas\\Code\\Reflection\\ClassReflection), 'Entry', 'getEntry', 'isEntry')\n
#1 \/home\/test\/test.it\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(293): Magento\\Framework\\Reflection\\NameFinder->getGetterMethodName(Object(Laminas\\Code\\Reflection\\ClassReflection), 'Entry')\n
#2 \/home\/test\/test.it\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(514): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('\\\\Magento\\\\Catalo...', Array)\n
#3 \/home\/test\/test.it\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(310): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, '\\\\Magento\\\\Catalo...')\n
#4 \/home\/test\/test.it\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(518): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Catalog...', Array)\n
#5 \/home\/test\/test.it\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(197): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, 'Magento\\\\Catalog...')\n
#6 \/home\/test\/test.it\/vendor\/magento\/module-webapi\/Controller\/Rest\/InputParamsResolver.php(98): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Catalog...', 'save', Array)\n
#7 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n
#8 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->___callParent('resolve', Array)\n
#9 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n
#10 \/home\/test\/test.it\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/InputParamsResolver\/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->___callPlugins('resolve', Array, Array)\n
#11 \/home\/test\/test.it\/vendor\/magento\/module-webapi\/Controller\/Rest\/SynchronousRequestProcessor.php(85): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->resolve()\n
#12 \/home\/test\/test.it\/vendor\/magento\/module-webapi\/Controller\/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n
#13 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
#14 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n
#15 \/home\/test\/test.it\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n
#16 \/home\/test\/test.it\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n
#17 \/home\/test\/test.it\/vendor\/magento\/framework\/App\/Http.php(116): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
#18 \/home\/test\/test.it\/vendor\/magento\/framework\/App\/Bootstrap.php(261): Magento\\Framework\\App\\Http->launch()\n
#19 \/home\/test\/test.it\/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n
#20 {main}"}What can I do?
Thank you
Hello @gbgssoftwad791
If you are receiving an error when trying to add a product with an image via API and JSON in Magento 2, there could be several possible causes. Here are some steps you can take to troubleshoot the issue:
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9