Persistent "Controller not found" error for custom API Action in EspoCRM 9.0.8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HareCom
    Junior Member
    • May 2025
    • 1

    #1

    Persistent "Controller not found" error for custom API Action in EspoCRM 9.0.8

    Hello EspoCRM Community,

    I'm encountering a persistent issue while trying to create a custom API action in my EspoCRM 9.0.8 installation. I've followed the documentation for creating custom API actions using Action classes, but I consistently receive a 'Controller not found' error.

    Here's a breakdown of what I've done:
    1. Created an Action class:
      • Located at custom/Espo/Custom/Api/EnvoyerSignatureAction.php
      • Namespace is Espo\Custom\Api
      • Implements the Action interface with a process method. (You can briefly describe what this method does, e.g., retrieves quoteId and calls an external script).
    2. Defined a custom route in routes.json:
      • Located at custom/Espo/Custom/Resources/routes.json
      • Content of routes.json: JSON
        {
        "routes": {
        "envoyer_signature_api": {
        "url": "/envoyer-signature",
        "method": "POST",
        "actionClassName": "Espo\\Custom\\Api\\EnvoyerSignatureAction",
        "auth": true
        }
        }
        }
      • (Mention if you've also tried using the params array with "action").
    3. Created a JavaScript handler:
      • Located at custom/client/envoyerASignature.js
      • It makes a POST request to envoyer-signature with the quoteId.
    4. Ensured app.json in custom/Espo/Custom/Resources/ does not contain rest or routes sections.
    5. I have cleared the cache and performed a rebuild after every change.

    The error I'm consistently getting in the espo.log is:
    [...timestamp...] WARNING: (404) Controller 'Envoyer-signature' does not exist. :: POST /envoyer-signature :: /home/xrqv3842/crm.adcop.fr/application/Espo/Core/Api/ControllerActionProcessor.php(189)


    Things I've already tried (you can mention these to avoid redundant suggestions):
    • Ensuring correct file paths and namespaces.
    • Verifying JSON syntax in routes.json.
    • Clearing cache and rebuilding multiple times.
    • Creating a modules.json file in the root directory (as one wasn't present).
    • Trying a simplified test API action and route.
    • (Mention any attempts to enable detailed error reporting).

    My questions for the community are:
    • Has anyone else encountered a similar 'Controller not found' error when trying to use actionClassName for custom API actions in version 9.0.8?
    • Are there any specific configuration settings in version 9.0.8 that might affect the loading of custom API actions defined via actionClassName?
    • Could there be an issue with the autoloader recognizing custom classes in the Api directory of a custom module?
    • Are there any other locations where custom API routes might be defined or overridden in version 9.0.8?
    • Any suggestions for further debugging steps I can take to pinpoint why the Action class isn't being recognized?

    Any help or insights would be greatly appreciated. Thank you in advance!
Working...