api-library: Error 404 accessing the API

Helo, I’m trying to access the Mautic API using Basic Authentication. Using the code below $contactApi = $api->newApi('contacts', $auth, AC_MAUTIC_URL . "/api");

I get the answer

object(Mautic\Api\Contacts)#445 (11) { ["endpoint":protected]=> string(8) "contacts" ["listName":protected]=> string(8) "contacts" ["itemName":protected]=> string(7) "contact" ["bcRegexEndpoints":protected]=> array(2) { ["contacts/(.*?)/dnc/(.*?)/add"]=> string(22) "contacts/$1/dnc/add/$2" ["contacts/(.*?)/dnc/(.*?)/remove"]=> string(25) "contacts/$1/dnc/remove/$2" } ["searchCommands":protected]=> array(11) { [0]=> string(3) "ids" [1]=> string(12) "is:anonymous" [2]=> string(10) "is:unowned" [3]=> string(7) "is:mine" [4]=> string(4) "name" [5]=> string(5) "email" [6]=> string(7) "segment" [7]=> string(7) "company" [8]=> string(5) "owner" [9]=> string(2) "ip" [10]=> string(6) "common" } ["bcTesting"]=> bool(false) ["endpointsSupported":protected]=> array(0) { } ["bcAttempt":protected]=> bool(false) ["baseUrl":protected]=> string(36) "https://inbound.dentalsigo.com//api/" ["auth":"Mautic\Api\Api":private]=> object(Mautic\Auth\BasicAuth)#441 (6) { ... ...

But if I try any command such as seeing a contact passing its id I always get the 404 reply as follows

array(2) { ["errors"]=> array(1) { [0]=> array(3) { ["message"]=> string(116) "Parece que encontrei um erro (error #404). Se fizer isso novamente, por favor comunique ao administrador do sistema!" ["code"]=> int(404) ["type"]=> NULL } } ["error"]=> array(2) { ["message"]=> string(212) "Parece que encontrei um erro (error #404). Se fizer isso novamente, por favor comunique ao administrador do sistema! (erroris deprecated as of 2.6.0 and will be removed in 3.0. Use theerrors array instead.)" ["code"]=> int(404) } }

I saw that a solution that serves many people is to clear the cache, but for me it did not help. I searched google for many hours for some solution, but none solved my case.

If anyone has any idea how to solve this please help me. Thank you

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 26 (10 by maintainers)

Most upvoted comments

Then it must be the cache problem. Try to clear it with rm -rf app/cache/*

@ryancwalsh typically it’s cache. If you’ve enabled the API you must also clear the caches before the API will work without 404. rm -rf app/cache/* is the nuclear cache-clearing option if others do not work.

Hey there, the cache is in var/cache since Mautic 3.

It is working, thanks a lot for the fast reply!

So the solution now is: rm -rf var/cache/*

Hey there, the cache is in var/cache since Mautic 3.

@escopecz I tried clearing cache, but again after few api calls response is 404. Any help ?

@jonaselan https://stackoverflow.com/questions/49491445/looks-like-i-encountered-an-error-error-404-in-mautic#comment91859340_50724012 You want to delete the app/cache folder within the Mautic installation rather than the Laravel installation. And if you are using a VM such as Homestead, you might need to SSH into the VM first.

@adrianoGaspar Can you please clarify what the solution was? I’ve been stuck for days in the same situation that you were in. I know that my credentials aren’t the problem because when I provide invalid ones I get “Authorization denied, invalid credentials”, as expected.

I’ve tried changing my URL to end in /api/, /api, /, and nothing. None of those help.

So I’m confused why I get “Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator!” for all the API endpoints.

And I don’t have a /app/cache folder to delete. Everyone talks about needing to delete that, but I’ve never seen one there at all.

Thanks in advance. 😃

cc @escopecz

I’m using laravel. I tried to use the test api and so far I did not get any type of response, nor the 404. It’s a bit complicated to adapt the test api to work with laravel, but I’ll keep trying.