Error is "message": "Internal Error. Details are available in Magento log file. Report ID: webapi-5dee36e254394".

When you run http://localhost:8888/magento/rest/V1/position/1

Need to get result from "position" column.

Api is for retrieving a column field by given user input.

 namespace SimpleMagento\Custom\Model;

use SimpleMagento\Custom\Api\InfoLinkInterface;
use SimpleMagento\Custom\Model\ResourceModel\Info\CollectionFactory; //Collection file
use SimpleMagento\Custom\Model\InfoFactory; //Implemented getter setter model

class InfoLink implements InfoLinkInterface
   private $collection;
   private $infoFactory;
   public function __construct(CollectionFactory $collection,InfoFactory $infoFactory)
 * @param int $id
 * @return \SimpleMagento\Custom\Api\Data\InfoInterface[]

public function getInfo($id)

    return $this->infoFactory->create()->getCollection()->addFieldToFilter('entity_id',$id)->getData();
    //return $this->infoFactory->create()->getData('position')->addFieldToFilter('entity_id',1);



webapi.xml is

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

<route url="/V1/position/:id" method="GET">
    <service class="SimpleMagento\Custom\Api\InfoLinkInterface" method="getInfo"/>
        <resource ref="anonymous" />

  • Can you please add here var/report/api or exception.log ? Dec 9 '19 at 13:02
  • 2019-12-09 12:57:41] main.CRITICAL: Report ID: webapi-5dee44c52bdb3; Message: Class SimpleMganeto\Custom\Model\InfoLink does not exist {"exception":"[object] (Exception(code: -1): Report ID: webapi-5dee44c52bdb3; Message: Class SimpleMganeto\\Custom\\Model\\InfoLink does not exist at /Applications/MAMP/htdocs/magento/vendor/magento/framework/Webapi/ErrorProcessor.php:205, ReflectionException(code: -1): Class SimpleMganeto\\Custom\\Model\\InfoLink does not exist at /Applications/MAMP/htdocs/magento/vendor/magento/framework/Code/Reader/ClassReader.php:19)"} [] Dec 9 '19 at 13:11
  • Make sure flush cache after change in di.xml file. Dec 9 '19 at 13:16

It seems like you added wrong model file class name in your di.xml file :

Change from :


To :


  • Thanks a lot for correction but not able to get, even after that. Code flow of developing API is corect, right? . To make it more simple I ll write SQL query , from which is I want to get result. **SELECT POISITION FROM NEW INFO WHERE ENTITY_ID=$ID ** Dec 10 '19 at 4:10
  • You added addFieldToFilter with entity_id. I think it should be position. Dec 10 '19 at 4:23
  • what you get data in getInfo function? Dec 10 '19 at 4:24
  • just a string from position column Dec 10 '19 at 4:27
  • If there will be unique record in your table. Then, you can use $record = $this->infoFactory->create()->getCollection()->addFieldToFilter('entity_id',$id)->getLastItem(); ................ and then you can return, $record->getPosition(); or $record['position']; Dec 10 '19 at 4:30

Try to replace this line

return $this->infoFactory->create()->getCollection()->addFieldToFilter('entity_id',$id)->getData();

With this one

return $this->infoFactory->create()->getCollection()->addFieldToFilter('entity_id',array('eq', $id))->getFirstItem()->getPosition();

Follow this link for reference.

Hope this will help you!


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.