# Mautic API Error: Requested URL not found

**URL:** <https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227>\
**Category:** Product Support\
**Created:** [January 19, 2017, 9:57pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227 "2017-01-19T21:57:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![flexmarkets](https://avatars.discourse-cdn.com/v4/letter/f/b3f665/32.png) [@flexmarkets](https://forum.mautic.org/u/flexmarkets)\
**Post date:** [January 19, 2017, 9:57pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/1 "2017-01-19T21:57:33Z")

</div>

Hey,  
  
  
  
I have a little problem:  
  
  
  
Situation: I want to call the **Mautic AP** I and get a response, which isn’t an error.  
  
  
  
I use the API library ([https://github.com/mautic/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.

Code:

\<?php

include **DIR**. ‘/vendor/autoload.php’;

use MauticAuthApiAuth;  
use MauticMauticApi;

$settings = array(  
‘baseUrl’ =\> ‘[http://mysite.com/mautic](http://mysite.com/mautic)’,  
‘version’ =\> ‘OAuth1a’,  
‘clientKey’ =\> ‘xxxxxxxxxxxxxxx’,  
‘clientSecret’ =\> ‘xxxxxxxxxxxxxxx’,  
‘callback’ =\> ‘[http://mysite.com/go.php](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](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!

---

<div class="post-metadata">

**Author:** ![flexmarkets](https://avatars.discourse-cdn.com/v4/letter/f/b3f665/32.png) [@flexmarkets](https://forum.mautic.org/u/flexmarkets)\
**Post date:** [January 19, 2017, 9:57pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/2 "2017-01-19T21:57:33Z")

</div>

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](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.

```auto

<?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!

---

<div class="post-metadata">

**Author:** ![rauljimenez](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@rauljimenez](https://forum.mautic.org/u/rauljimenez)\
**Post date:** [February 6, 2017, 5:51pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/3 "2017-02-06T17:51:44Z")

</div>

Same problem…  
Any hint on this issue?

---

<div class="post-metadata">

**Author:** ![naomicbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/naomicbush/32/93_2.png) [@naomicbush](https://forum.mautic.org/u/naomicbush)\
**Post date:** [February 6, 2017, 7:06pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/4 "2017-02-06T19:06:54Z")

</div>

@rauljimenez it’s been solved many times 🙂 clear your cache

[https://www.mautic.org/community/index.php/6801-help-thriveleads-api-is-not-populating-contact-segments-list](https://www.mautic.org/community/index.php/6801-help-thriveleads-api-is-not-populating-contact-segments-list)

[https://wordpress.org/support/topic/oauth-1-add-new-blank-page-oauth-2-404-error/](https://wordpress.org/support/topic/oauth-1-add-new-blank-page-oauth-2-404-error/)

[https://www.mautic.org/community/index.php/6583-api-call-returns-404/p1#p18700](https://www.mautic.org/community/index.php/6583-api-call-returns-404/p1#p18700)

[https://www.mautic.org/community/index.php/6687-mautic-api-error-requested-url-not-found/p1#p19115](https://www.mautic.org/community/index.php/6687-mautic-api-error-requested-url-not-found/p1#p19115)

Slack:  
 ![](https://cloud.githubusercontent.com/assets/918242/22626934/e0fb06be-eb85-11e6-9649-faf94119846f.png)

Here’s the correct way to do it:

[https://mautic.org/docs/en/tips/troubleshooting.html](https://mautic.org/docs/en/tips/troubleshooting.html)

---

<div class="post-metadata">

**Author:** ![eknimation](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/eknimation/32/165_2.png) [@eknimation](https://forum.mautic.org/u/eknimation)\
**Post date:** [March 22, 2017, 12:11pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/5 "2017-03-22T12:11:44Z")

</div>

@naomicbush thank you. That solved my problem too.

---

<div class="post-metadata">

**Author:** ![process.env](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/process.env/32/1097_2.png) [@process.env](https://forum.mautic.org/u/process.env)\
**Post date:** [October 15, 2020, 7:22pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/6 "2020-10-15T19:22:06Z")

</div>

Running the command mentioned above didn’t fix the problem for me, but I fixed it by running the clear:cache command from Mautic - the command will look something like:  
`php /var/www/html/mautic/bin/console cache:clear`  
( _change the path to your Mautic installation - and **if you have a pre-3 version** , it will be “ `app/console` ” for you instead of “ `bin` ”_ )

(PD: If you get some “can’t locate php” error, change the “ `php` ” part of the code by the path you have in your crons pointing to php (to find it, write “ `crontab -e` ” or “ `sudo crontab -e` ” on the command line and copy the string/path between “-c” and “-q” _(which in my case is “/opt/bitnami/php/bin/php” since I installed it through Bitnami)_

---

<div class="post-metadata">

**Author:** ![muldersc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/muldersc/32/6471_2.png) [@muldersc](https://forum.mautic.org/u/muldersc)\
**Post date:** [October 3, 2022, 6:14pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/7 "2022-10-03T18:14:36Z")

</div>

If / when this blows up someone’s setup… try the advice here to check that your site setting in the local.php file is prefixed correctly (http or https) to match whatever load-balancer / redirection scheme you have.

> [@Mautic went down after cache clearing](https://forum.mautic.org/t/mautic-went-down-after-cache-clearing/23377/22):
>

---

<div class="post-metadata">

**Author:** ![edwin.muniu](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@edwin.muniu](https://forum.mautic.org/u/edwin.muniu)\
**Post date:** [May 17, 2023, 9:43pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/8 "2023-05-17T21:43:54Z")

</div>

I am trying to add a new contact from pabbly to mautic, I get this error

Requested URL not found: //api/contacts/new  
404.

I have cleared cache but still doesnt work please assist

1. php /var/www/html/mautic/bin/console cache:clear
2. rm -rf var/cache/\*

---

<div class="post-metadata">

**Author:** ![edwin.muniu](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@edwin.muniu](https://forum.mautic.org/u/edwin.muniu)\
**Post date:** [May 18, 2023, 8:23am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/9 "2023-05-18T08:23:25Z")

</div>

Mautic 4.4.8

I have done some reading and noted that there is someone who said another issue is the double slashes.

my url has double slashes. kindly let me know where I can remove the double slashes in mautic

my error:  
Requested URL not found: //api/contacts/new  
404.

> [@edwin.muniu](#):
>
> I am trying to add a new contact from pabbly to mautic, I get this error
> 
> Requested URL not found: //api/contacts/new  
> 404.
> 
> I have cleared cache but still doesnt work please assist
> 
> 1. php /var/www/html/mautic/bin/console cache:clear
> 2. rm -rf var/cache/\*

* * *

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [May 18, 2023, 8:31am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/10 "2023-05-18T08:31:23Z")

</div>

Hi, you can remove it here:  
Gear icon \> Configuration \> System settings \> Site URL : remove the trainling slash from the end of your URL

---

<div class="post-metadata">

**Author:** ![edwin.muniu](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@edwin.muniu](https://forum.mautic.org/u/edwin.muniu)\
**Post date:** [May 18, 2023, 9:17am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/11 "2023-05-18T09:17:53Z")

</div>

Hi,

I confirm that this is well set as per your instructions

Gear icon \> Configuration \> System settings \> Site url  
[https://mautic.domain.com](https://mautic.domain.com)

\*\*\*\* ERROR \*\*\*  
However, I still get the double slash error

my error:  
Requested URL not found: //api/contacts/new  
404.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [May 18, 2023, 9:44am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/12 "2023-05-18T09:44:53Z")

</div>

How does your call look like?  
Maybe you are still calling at [yourcomain.com//api](http://yourcomain.com//api) … ?

---

<div class="post-metadata">

**Author:** ![edwin.muniu](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@edwin.muniu](https://forum.mautic.org/u/edwin.muniu)\
**Post date:** [May 19, 2023, 9:05am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/13 "2023-05-19T09:05:25Z")

</div>

the base url is well set without / slash at the end…

Otherwise I decided to delete connection and do a fresh one. Unfortunately I have digressed! as now connection wont work after clearing cache and also Enabling API and HTTP basic auth

---

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [May 19, 2023, 9:28am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/14 "2023-05-19T09:28:32Z")

</div>

Is it installed in a subdirectory … es with the initial post?  
Don’t forget to adjust the provided .htaccess - as this only works with Mautic in root folders of the webserver document directory. If Mautic runs on TLD/mautic/ or similar, .htaccess needs an edit after each update.

---

<div class="post-metadata">

**Author:** ![edwin.muniu](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@edwin.muniu](https://forum.mautic.org/u/edwin.muniu)\
**Post date:** [May 19, 2023, 10:20am UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/15 "2023-05-19T10:20:53Z")

</div>

hi.

I create my mautic. in a subdomain [http://mautic.domain.com](http://mautic.domain.com) however, the actual directory is  
/public\_html/mautic

kindly could you give actual code I can add to .htacess

I appreciate this!!!

---

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [May 19, 2023, 1:16pm UTC](https://forum.mautic.org/t/mautic-api-error-requested-url-not-found/7227/16 "2023-05-19T13:16:16Z")

</div>

If the Mautic is available at the root of your subdomain, the .htaccess is not your problem.

So the dashboard appears at [http://mautic.domain.com/s/dashboard](http://mautic.domain.com/s/dashboard) - not [http://mautic.domain.com/mautic/s/dashboard](http://mautic.domain.com/mautic/s/dashboard)?

Then this issue can be ignored, doesn’t apply to you.

Question: you did enable Mautic API first, right? Its disabled by default.

(P.S. hope you mean https, not http :P)
