Announcement

Collapse
No announcement yet.

Error when creating a new lead via API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when creating a new lead via API

    I created and uploaded the file EspoApiClient.php to the main directory

    Created a PHP file with this code as in the example
    ------------------------------------------------

    <?php

    require_once('EspoApiClient.php');

    $url = 'https://aaaaaaaaaex.com/crm/';
    $apiKey = 'bdaaaaaaaaaaaaaaaaaaaaaaaaa2e';

    $client = new EspoApiClient($url);
    $client->setApiKey($apiKey);

    // example creating a new lead
    try {
    $response = $client->request('POST', 'Lead', [
    'firstName' => 'Test',
    'lastName' => 'Hello',
    ]);
    } catch (\Exception $e) {
    $errorCode = $e->getCode();
    }

    ----------------------------------------
    The API user has the right to create a lead
    I get this error on startup


    [2022-08-07 13:25:05] ERROR: 404 Not Found Type: Slim\Exception\HttpNotFoundException Code: 404 Message: Not found. File: /home/aaaaaaaaex/public_html/crm/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php Line: 93 Trace: #0 /home/aaaaaaaax/public_html/crm/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(59): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) EspoCRM Forum /home/aaaaaaaaaaaa/public_html/crm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(140): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner)) Forum /home/aaaaaaaaaa/public_html/crm/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): class@anonymous->handle(Object(Slim\Psr7\Request)) #3 /home/aaaaaaaaaa/public_html/crm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(140): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #4 /home/aaaaaaaa/public_html/crm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): class@anonymous->handle(Object(Slim\Psr7\Request)) Groups /home/aaaaaaaaa/public_html/crm/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) Uncategorized Groups /home/aaaaaaaaaa/public_html/crm/vendor/slim/slim/Slim/App.php(199): Slim\App->handle(Object(Slim\Psr7\Request)) Special /home/aaaaaaaaaa/public_html/crm/application/Espo/Core/ApplicationRunners/Api.php(94): Slim\App->run() Visitor Messages /home/aaaaaaaaa/public_html/crm/application/Espo/Core/Application.php(95): Espo\Core\ApplicationRunners\Api->run() Private Messages /home/aaaaaaaaaa/public_html/crm/api/v1/index.php(37): Espo\Core\Application->run('Espo\\Core\\Appli...') Albums {main} Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor. [] []

  • #2
    Hi sobolevfff,

    Please try to remove these lines:
    Code:
    try {
    } catch (\Exception $e) {
    $errorCode = $e->getCode();
    }

    Comment

    Working...
    X