API Returning 401 when I try to create a session

I have a new install with the API enabled. I used the sample curl command (with the missing space before the --data) and it worked.

I have a php script that I have used on a previous install to do a test session create. When I run it on the same account as the new install I get a 401 error.

If I run the exact same script on another account connecting to the new install, with the same hosting company, it runs fine.

So I don’t believe that there is a phplist API problem. But I can’t figure out why I am getting the 401 error when I run it on the same account as new install. I can’t figure out how to get any logs that might tell me why I get the 401. I have tried turning on debug per the troubleshooting and API troubleshooting pages but nothing is ever generated. Any suggestions about how to debug this would be appreciated.

More information. Now I am suspicious that they may be something wrong with the installation and/or PHPList.

I have two accounts on the same hosting provider (A2hosting). Both accounts are the same type and both are running PHP 8.

Account J was my original installation. After a lot of messing around I was able to get the API working.

Account F is my new installation. I believe I set it up the same as account J.

To test the API on both accounts I have been using the curl command noted on the API page. What is curious is that I see different results on different accounts.

The curl command to the J account looks like:
curl --request POST --url https://jaccountdomain.com/lists/api/v2/sessions --header ‘Content-Type: application/json’ --data ‘{“login_name”: “admin”,“password”: “changed”}’

The curl command to the F account looks like:
curl --request POST --url https://faccountdomain.com/lists/api/v2/sessions --header ‘Content-Type: application/json’ --data ‘{“login_name”: “admin”,“password”: “changed”}’

On the F account, I can run the curl commands to both installations and they both work fine. When I go to the J account, the curl command to its installation works fine but when I run it against the F installation it returns HTML.
I am struggling to know where to even start troubleshooting this.

I did a clean install on the “J” account and everything works fine. Deleted everything off of the “F” account and did a clean install. The command line curl works, as before. The PHP program is failing with the 401 error. The same PHP program works fine on the “J” account with just the url, and password changed.

I turned on API logging per the instructions but even after I rerun the test program there is nothing in the error_log. The API troubleshooting page doesn’t say where the output will go.

I added a new user with a new password and now it works fine. I would still like to know how to get logging working and where they go.