main.CRITICAL: Report ID: webapi-61d924815c991; Message: Class type does not exist {"exception":"[object] (Exception(code: -1): Report ID: webapi-61d924815c991; Message: Class type does not exist at /var/www_magento/apimagento/vendor/magento/framework/Webapi/ErrorProcessor.php:208, ReflectionException(code: -1): Class type does not exist at /var/www_magento/apimagento/vendor/magento/framework/Webapi/ServiceInputProcessor.php:264)"} []
etc/module.xml
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/manageuser/createuser" method="POST">
<service class="MobileApi\PhoneUser\Api\PhoneUserManageInterface" method="registerPhoneUser"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/manageuser/get" method="POST">
<service class="MobileApi\PhoneUser\Api\PhoneUserManageInterface" method="getUserByMobile"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/manageuser/login" method="POST">
<service class="MobileApi\PhoneUser\Api\PhoneUserManageInterface" method="doPhoneLogin"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
Api/PhoneUserManageInterface.php
<?php
namespace MobileApi\PhoneUser\Api;
/**
* @api
*/
interface PhoneUserManageInterface
{
/**
* Make the login with user mobile number
* @param string $phonenumber
* @return string Token created
* @throws \Magento\Framework\Exception\AuthenticationException
*/
public function doPhoneLogin($phonenumber);
/**
* get details of user using mobile number
* @param string $phonenumber
* @return string user_email
* @throws \Magento\Framework\Exception\AuthenticationException
*/
public function getUserByMobile($phonenumber);
/**
* create new user
* @param type $firstName
* @param type $lastName
* @param type $email
* @param type $phonenumber
* @return mixed token
* @throws \Magento\Framework\Exception\AlreadyExistsException
*/
public function registerPhoneUser($firstName, $lastName, $email, $phonenumber);
}
model/PhoneUserManage.php
<?php
namespace MobileApi\PhoneUser\Model;
use MobileApi\PhoneUser\Api\PhoneUserManageInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
use Magento\Customer\Model\Customer;
use Magento\Customer\Model\CustomerFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\State\InputMismatchException;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Integration\Model\Oauth\TokenFactory as TokenModelFactory;
use Magento\Customer\Api\Data\CustomerExtensionFactory;
use Magento\Framework\Webapi\ServiceInputProcessor;
use Magento\Framework\Webapi\ErrorProcessor;
class PhoneUserManage implements PhoneUserManageInterface
{
/**
* Token Model
*
* @var TokenModelFactory
*/
private $tokenModelFactory;
/**
* @type StoreManagerInterface
*/
protected $storeManager;
/**
* @type CustomerFactory
*/
protected $customerFactory;
/**
* @var CustomerInterfaceFactory
*/
protected $customerDataFactory;
/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
/**
* @var CustomerExtensionFactory
*/
protected $customerExtensionFactory;
/**
* user constructor.
* @param CustomerFactory $customerFactory
* @param CustomerInterfaceFactory $customerDataFactory
* @param CustomerRepositoryInterface $customerRepository
* @param StoreManagerInterface $storeManager
* @param TokenModelFactory $tokenModelFactory
*/
public function __construct(
CustomerFactory $customerFactory,
CustomerInterfaceFactory $customerDataFactory,
CustomerRepositoryInterface $customerRepository,
StoreManagerInterface $storeManager,
TokenModelFactory $tokenModelFactory,
CustomerExtensionFactory $customerExtensionFactory
) {
$this->customerFactory = $customerFactory;
$this->customerRepository = $customerRepository;
$this->customerDataFactory = $customerDataFactory;
$this->storeManager = $storeManager;
$this->tokenModelFactory = $tokenModelFactory;
$this->customerExtensionFactory = $customerExtensionFactory;
}
/**
*
* @param type $firstName
* @param type $lastName
* @param type $email
* @param type $phonenumber
* @return string
* @throws AlreadyExistsException
*/
public function createPhoneUser($firstName, $lastName, $email, $phonenumber){
return "createPhoneUser {$phonenumber} on ".date('d/m/Y H:i:s');
}
public function doPhoneLogin($phonenumber)
{
return "doPhoneLogin {$phonenumber} on ".date('d/m/Y H:i:s');
}
public function getUserByMobile($phonenumber)
{
return "getUserByMobile {$phonenumber} on ".date('d/m/Y H:i:s');
}
}
here strange thing is doPhoneLogin & getUserByMobile working without error. but when i try createPhoneUser i get above error.
please guide me fix this issue.
/**
* create new user
* @param type $firstName
* @param type $lastName
* @param type $email
* @param type $phonenumber
* @return mixed token
* @throws \Magento\Framework\Exception\AlreadyExistsException
*/
public function registerPhoneUser($firstName, $lastName, $email, $phonenumber);
should be (IIRC you should also probably then delete the generated, at the very least, after the changes)
/**
* create new user
* @param string $firstName
* @param string $lastName
* @param string $email
* @param string $phonenumber
* @return mixed
* @throws \Magento\Framework\Exception\AlreadyExistsException
*/
public function registerPhoneUser($firstName, $lastName, $email, $phonenumber);
Services get defined from doc blocks in the Interfaces and any typos or mistakes in them will break things. Read more at devdocs for rules and details