menu

Questions & Answers

t3api extension is returning a 404 page not found TYPO3

I am trying to add custom API-s endpoints to my TYPO3 CMS. Here is the model for my Projects.

namespace Geraldib\PortfolioSite\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use SourceBroker\T3api\Annotation\ApiResource;

/**
 * @ApiResource(
 *     collectionOperations={
 *          "get"={
 *              "path"="/projects",
 *          },
 *     },
 * )
 */
class Project extends AbstractEntity
{

I have also included this code in my config.yaml

imports:
  - { resource: "EXT:t3api/Configuration/Routing/config.yaml" }

Here is the Response it returns.

enter image description here

I was expecting a array of all projects to be returned. Should I implement this route in my controller if so because I don't see anything in the docs.

Answers(1) :

The Urls in your screenshot does not correspond to anything common to a TYPO3 installation. (Which TYPO3 version do you use?)

A typical TYPO3 installation would consist on this folder structure:

starting with a installation root which would be something like: /srv/www/htdocs/projectname.
There you have multiple folders with public/ as the folder which represents the web root:
/srv/www/htdocs/projectname/public (https://mydomain/)

Up to TYPO3 11 in the web root you have a folder typo3conf/ with a subfolder ext/ where all extensions are stored:
/srv/www/htdocs/projectname/public/typo3conf/ext/ or https://mydomain/typo3conf/ext/

So files of the extension t3api (which could be addresses inside of TYPO3 as ext:t3api/...) would be accessible as /srv/www/htdocs/projectname/public/typo3conf/ext/t3api/... on server side
or https://mydomain/typo3conf/ext/t3api/... on client side.

Your URLS look like a mix of local and client paths, which probably will fail.