2

am using Webkul_BookingSystem extension for booking slot in magento2.1.7. The issue what I got here: While I add the product details in to cart through Rest API the Slot class showing does not have setter class in CartItemInterface.

webapi.xml file of this extension:

<?xml version="1.0"?>

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd">
    <route url="/V1/bookingsystem/slot" method="POST">
        <service class="Webkul\BookingSystem\Api\Data\SlotInterface" method="setStore"/>
        <resources>
            <resource ref="Webkul_BookingSystem::setStore"/>
        </resources>
    </route>
</routes>

Api/Data/SlotInterface.php

 <?php
    /**
     * Webkul Software.
     *
     * @category  Webkul
     * @package   Webkul_BookingSystem
     * @author    Webkul
     * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https://webkul.com)
     * @license   https://store.webkul.com/license.html
     */
    namespace Webkul\BookingSystem\Api\Data;

    interface SlotInterface
    {
        /**
         * Constants for keys of data array. Identical to the name of the getter in snake case.
         */
        const ENTITY_ID = 'id';
        /**#@-*/

        /**
         * Get ID.
         *
         * @return int|null
         */
        public function getId();

        /**
         * Set ID.
         *
         * @param int $id
         *
         * @return \Webkul\BookingSystem\Api\Data\SlotInterface
         */
        public function setId($id);
    }

Url pass in postman: http://mysite/V1/bookingsystem/slot Method: POST.

data in form:
{
"cart_item": {
"quote_id": "11",
"sku": "newbookingproduct",
"qty": 1,
"Slots": {
"2":
{
"booking_from" : "26 November, 2017, 01:06 AM",
"booking_to" : "26 November, 2017, 01:11 AM"
}
}
}
}

Error message:

    {
"message": "Property \"Slots\" does not have corresponding setter in
class \"Magento\\Quote\\Api\\Data\\CartItemInterface\".",
"trace": "#0
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\Reflection\\NameFinder.php(59):
Magento\\Framework\\Reflection\\NameFinder->findAccessorMethodName(Object(Zend\\Code\\Reflection\\ClassReflection),
'Slots', 'getSlots', 'isSlots')\n#1
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\Webapi\\ServiceInputProcessor.php(158):
Magento\\Framework\\Reflection\\NameFinder->getGetterMethodName(Object(Zend\\Code\\Reflection\\ClassReflection),
'Slots')\n#2
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\Webapi\\ServiceInputProcessor.php(322):
Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Quote\\\\A...',
Array)\n#3
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\Webapi\\ServiceInputProcessor.php(119):
Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array,
'Magento\\\\Quote\\\\A...')\n#4
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\module-webapi\\Controller\\Rest\\InputParamsResolver.php(101):
Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Quote\\\\A...',
'save', Array)\n#5
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\module-webapi\\Controller\\Rest.php(299):
Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n#6
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\module-webapi\\Controller\\Rest.php(216):
Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#7
D:\\xampp\\htdocs\\dashboard\\api\\var\\generation\\Magento\\Webapi\\Controller\\Rest\\Interceptor.php(24):
Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#8
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\App\\Http.php(135):
Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#9
D:\\xampp\\htdocs\\dashboard\\api\\vendor\\magento\\framework\\App\\Bootstrap.php(258):
Magento\\Framework\\App\\Http->launch()\n#10
D:\\xampp\\htdocs\\dashboard\\api\\index.php(39):
Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#11
{main}"
}
0

You should be able to get around this by using extension attributes. The magento docs describe how this can be done for the product interface / repository.

http://devdocs.magento.com/guides/v2.0/extension-dev-guide/extension_attributes/adding-attributes.html

However this is obviously something that the extension provider should resolve.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.