0

REST API returns Error:

{
    "messages": {
        "error": [
            {
                "code": 500,
                "message": "Fatal Error: 'Uncaught Error: Cannot instantiate interface MyCompany\\Slider\\Api\\SlidesRepositoryInterface in /var/www/html/magento.lan/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:50\nStack trace:\n#0 /var/www/html/magento.lan/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\\Framework\\ObjectManager\\Factory\\Dynamic\\Developer->create('MyCompany\\\\Adva...')\n#1 /var/www/html/magento.lan/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(90): Magento\\Framework\\ObjectManager\\ObjectManager->get('MyCompany\\\\Adva...')\n#2 /var/www/html/magento.lan/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#3 /var/www/html/magento.lan/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 /var/www/html/magento.lan/vendor/magento/framework/Interc' in '/var/www/html/magento.lan/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php' on line 50",
                "trace": "Trace is not available."
            }
        ]
    }
}

I also run all Cli :

rm -rf var/cache/* var/tmp/_cache var/composer_home/cache/* var/view_preprocessed/* var/page_cache/* var/report/* var/log/* generated/code/*  pub/static/frontend/* pub/static/adminhtml/* pub/static/_cache/*
php bin/magento setup:di:compile
php bin/magento s:up
php -d memory_limit=2G bin/magento index:reindex
php bin/magento c:f

cat /var/log/nginx/error.log

Stack trace:
#0 /var/www/html/magento.lan/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('MyCompany\\Adva...')
#1 /var/www/html/magento.lan/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(90): Magento\Framework\ObjectManager\ObjectManager->get('MyCompany\\Adva...')
#2 /var/www/html/magento.lan/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))
#3 /var/www/html/magento.lan/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#4 /var/www/html/magento" while reading response header from upstream, client: 127.0.0.1, server: www.magento.lan, request: "GET /rest/default/V1/apps/abanners HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "www.magento.lan"
1
  • Can you see the error in log file of server. Also, you did run di compile after defining interface in di.xml
    – Ankit
    Mar 29 at 11:17
1

Usually the 500 error code its from the server, so as I see it its from PHP compiling.

The problem is with MyCompany\Slider\Api\SlidesRepositoryInterface , have you implemented it correctly, does it have in di.xml reference to it?

Vinai Kopp has a really nice explanation of it.

Magento 2 Repositories, Interfaces and the Web API

2
  • i also thinking interface issue
    – matinict
    Mar 29 at 11:31
  • yes i got error on MyCompany\Slider\Api\Data;
    – matinict
    Mar 29 at 11:59

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.