Mautic API Error: Requested URL not found

Hey,

I have a little problem:

Situation: I want to call the Mautic API and get a response, which isn’t an error.

I use the API library (https://github.com/mautic/api-library).
The API is enabled in the configuration settings and I have authorized my requests with oAuth1a.
Everything’s working fine with the authorization.

Mautic is installed in the subdirectory ‘mautic’.

Whenever I make a call to the API I get the response, that the requested URL has not been found:

The $json_response of the following code is:

{“contact”:{“error”:{“message”:“Requested URL not found: /mautic/api/contacts/new”,“code”:404}}}

So /mautic/api/contacts/new has not been found. This happens with every endpoint!
Even when I use the API Tester exactly the same happens.


<?php

include __DIR__ . '/vendor/autoload.php';

use MauticAuthApiAuth;
use MauticMauticApi;


$settings = array(
    'baseUrl'           => 'http://mysite.com/mautic',  
    'version'           => 'OAuth1a', 
    'clientKey'         => 'xxxxxxxxxxxxxxx', 
    'clientSecret'      => 'xxxxxxxxxxxxxxx',     
    'callback'          => 'http://mysite.com/go.php', // used before to get access tokens (see below)
    'accessToken'       => 'xxxxxxxxxxxxxxx', // <-- hard coded access token data
    'accessTokenSecret' => 'xxxxxxxxxxxxxxx' // <-- hard coded access token data
);


$initAuth   = new ApiAuth();
$auth       = $initAuth->newAuth($settings);
$apiUrl     = "http://mysite.com/mautic";
$api        = new MauticApi();


$contactApi = $api->newApi("contacts", $auth, $apiUrl);


$data = array(
    'firstname' => 'Jim',
    'lastname'  => 'Contact',
    'email'     => 'jim@his-site.com',
    'ipAddress' => $_SERVER['REMOTE_ADDR']
);


$contact = $contactApi->create($data);


$json_response['contact'] = $contact;

header('Content-Type: application/json');
echo json_encode($json_response);

Does anybody know a solution for that?

Thanks a lot!