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?


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

namespace Vendor\Module\Api;
interface SampleInterface
 * GET for Post api
 * @param string $customerId
 * @return \Vendor\Module\Api\Data\ResponseDataInterface

public function getDetails($customerId);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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