api-library: Error code 404 when request API
I try to request Mautic API with an end point http://localhost/api/contacts/1 and I got the following error
{ "errors": [ { "message": "Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator!", "code": 404, "type": null } ], "error": { "message": "Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! (
erroris deprecated as of 2.6.0 and will be removed in 3.0. Use the
errors array instead.)", "code": 404 } }
I already clear my mautic cache but it didn’t resolved my problem. And i already check the logs but there isn’t error can you help me
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (8 by maintainers)
In my case, I solved it by removing the cache in another directory:
var/cache/prod/
. Run:If
/*
is not presented, then the prod directory is removed and may occours problems in the future.delete app/cache from mautic project folder.
@ariyo thank you for your experience! I’m sure it will help others in similar situation.There are a couple of things that should not happen though so I want to point them out that it’s not how it’s suppose to be.
index.php
in your Mautic URL then you don’t have properly configured server. Check if.htaccess
andmod_rewrite
is enabled. It should not be there.For people who may still be running into this. In my case I fixed it on my instance. Read on…
I cleared cache and everything stoped working. Refreshed Mautic on the browser and I got the “contact your administrator” error 😱 ! Looking at the logs I saw that the cache folder was not writeable. I fixed it by running:
sudo chown -R www-data:www-data /var/www/html
--> Read the fix below before your run this command. Then I refreshed the browser and everything was running again!The actual FIX: Turned out the API endpoint was not
https://your-mautic-instance.com/api
it ishttps://you-mautic-instance.com/index.php/api
in fact to get the accurate base url, go to your Mautic configuration > System Settings and look at theSite URL
That should be your API base URL. That was simply what it was for me. I hope it helps someone out there!If you turned the API on via the backend there is cache and you should clear it.
@escopecz thanks for the solution, so i delete manualy all of the cache file and change the permision of the new cache file that mautic’s created but when i open http://localhost/api/ the error still same but when i open http://localhost/api/contacts it show the result
@escopecz i don’t know what he means about the api (** .with // api) and also when i try with http://localhost/api/ end point it’s still have the same problem so i don’t think the problem is same
Read through https://github.com/mautic/api-library/issues/156