In Magento 2.4, I am using custom API and it is giving the below error.
{
"message": "Class string does not exist",
"code": -1
}
I have tried this and this solution. But nothing worked. Any solution for this?
asked Apr 18, 2023 at 12:03
-
Can you share code?Zahid Hussain Magento– Zahid Hussain Magento2023年04月18日 21:49:04 +00:00Commented Apr 18, 2023 at 21:49
1 Answer 1
I found the issue. In my case, It is due to the return type of the response specified in the Interface file(Usually at Api/Interface.php).
Sample code:
here it is: @return \Vendor\Module\Api\Data\ResponseDataInterface
<?php
namespace Vendor\Module\Api;
interface SampleInterface
{
/**
* GET for Post api
* @param string $customerId
* @return \Vendor\Module\Api\Data\ResponseDataInterface
*/
public function getDetails($customerId);
}
answered Apr 19, 2023 at 15:15
default