Errors 401, 403 and 404 calling Mautic API

Your software
My Mautic version is: 4.3.1
My PHP version is: PHP Version 8.0.28
My Database type and version is: MySQL
Hosting provider ptISP

Your problem
My problem is: Always Get error 401, 403, 404 while calling API using basic authentication

I’m starting to explore API’s and specifically Mautic API in order to integrate myMautic at Mautic and my osclass at https://www.atol.pt

The purpose is to automatically add an email address to Mautic when a new user registers, instead of going to Mautic to register it.

I’m using postman, but also a python program i made to call REST web services, to get a reply from https://services.atol.pt/mautic/api/contacts

I have also created a user for this, and it has the admin role, i know too much power for an API user, after it’s working I’ll try to find the best role to it, but nevertheless it’s that.

When i call https://services.atol.pt/mautic/api/contacts/ i get a 401 error, after fiddling with the request I started getting error 401 and 403 and sometimes between call I get 404.

Can anyone help and tell me what might i be doing wrong ? or what is wrong with my setup ?

Also do you know if there is a Mautic with public API so that i can try and learn Mautic api and compare with mine.

Thanks,
Best Regards

First I would check that basic auth. is enabled in mautic settings. if its i would enable it and clear the cache with:

rm -rf /var/cache/dev/* /var/cache/prod/*

Mautic setting and auth are as documented and seem ok to me.
Didin’ remove the cache dir, have seen it advised many times and the consequent reply saying id didn’t solve, but nevertheless I didn’t go there yet.

Did it, removed the entire /var/cache/prod folder, when I logged into Mautic the folder was automatically recreated.
No dev folder exists.

The result is the same.
If you can help giving some more hints appreciate it, I will continue digging into into until I find the solution.

My objective is to integrate osclass and Mautic, but also Dolibarr, and I’ll use fusion-project.org to integrated these.
Guess i’ll have to go from problem to problem until i get it all together.

I would make sure you are specifying username and pass in the http request correctly.

Also with the command I gave you, I am not removing prod folder but just the contents of this folder.

Anyway if you are interested I can take a look into your issue myself on the call and see if I can do something to make it work (please reach out over PM, if interested).

I’ll try to figure it out in this weekend and if not capable I’ll PM you and appreciate your help.
I’ll be looking into external factors like modsec and cloudflare.

1 Like

The problem was solved, unfortunately I don’t realize how.
After all the testing I opened postman this weekend and the call worked!
I was fiddling with disconnecting some security options, modes, and other available on my cPanel.
For each security option turned off, that i turned off, tested, without success, and turned it back on.
In the end the service started replying.
I thought, maybe something I forgot to turn back on, unfortunately no, had PrtScrn for each changed option.
So I can only suspect that by turning off and back on some option it may have done something.
Still when I figure out what it was I’ll give feedback here.
Thanks for your patience.