cancel
Showing results for 
Search instead for 
Did you mean: 

Create tax class using rest api with extension attributes

Create tax class using rest api with extension attributes

Hi,
I am trying to create a tax class using API with extension attribute, rest/V1/taxClasses using.

some_custom_data is a column on the tax class table, I want to save data to it.
This is the payload

{
"taxClass": {
"class_name": "string4",
"class_type": "CUSTOMER",
"extension_attributes": {
"some_custom_data": "2"
}

I'm getting the following error  

"message": "Property \"SomeCustomData\" does not have accessor method \"getSomeCustomData\" in class \"Magento\\Tax\\Api\\Data\\TaxClassEExtensionInterface\".",
    "trace": "#0 /var/www/html/eleczo233/vendor/magento/framework/Reflection/NameFinder.php(59): Magento\\Framework\\Reflection\\NameFinder->findAccessorMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), 'SomeCustomData', 'getSomeCustomDa...', 'isSomeCustomDat...')\n#1 /var/www/html/eleczo233/vendor/magento/framework/Webapi/ServiceInputProcessor.php(260): Magento\\Framework\\Reflection\\NameFinder->getGetterMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), 'SomeCustomData')\n#2 /var/www/html/eleczo233/vendor/magento/framework/Webapi/ServiceInputProcessor.php(480): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('\\\\Magento\\\\Tax\\\\Ap...', Array)\n#3 /var/www/html/eleczo233/vendor/magento/framework/Webapi/ServiceInputProcessor.php(277): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, '\\\\Magento\\\\Tax\\\\Ap...')\n#4 /var/www/html/eleczo233/vendor/magento/framework/Webapi/ServiceInputProcessor.php(480): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Tax\\\\Api...', Array)\n#5 /var/www/html/eleczo233/vendor/magento/framework/Webapi/ServiceInputProcessor.php(165): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, 'Magento\\\\Tax\\\\Api...')\n#6 /var/www/html/eleczo233/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Tax\\\\Api...', 'save', Array)\n#7 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n#8 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->___callParent('resolve', Array)\n#9 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->Magento\\Framework\\Interception\\{closure}()\n#10 /var/www/html/eleczo233/generated/code/Magento/Webapi/Controller/Rest/InputParamsResolver/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->___callPlugins('resolve', Array, Array)\n#11 /var/www/html/eleczo233/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(85): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver\\Interceptor->resolve()\n#12 /var/www/html/eleczo233/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#13 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#14 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#15 /var/www/html/eleczo233/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#16 /var/www/html/eleczo233/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#17 /var/www/html/eleczo233/vendor/magento/framework/App/Http.php(137): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#18 /var/www/html/eleczo233/vendor/magento/framework/App/Bootstrap.php(261): Magento\\Framework\\App\\Http->launch()\n#19 /var/www/html/eleczo233/index.php(40): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#20 {main}"
}

 

1 REPLY 1

Re: Create tax class using rest api with extension attributes

Hi @raju_a,

 

Please check your plugin class for the save method. Also try to create your extension attribute like this :

<extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
        <attribute code="custom_data" type="Magento\SomeModule\Api\Data\CustomDataInterface" />
    </extension_attributes>

 In the interface try to add getCustomData and setCustomData methods for the extension attribute.

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/extension_attributes/adding-attributes.h...

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!