API V2 not working for 3.6.10 installation

Have 3.6.10 installed and tested. Using the GUI have been able to do all normal stuff like create campaign, send email, etc.

Now trying to use the API. The documentation talks about how to enable the API and test it. However, even after enabling it, the endpoint for testing does not exist. Digging into the code, it appears that all of the code for V2 is there.

I installed manually and a second time through Softaculous. In neither case was the endpoint created. I have spent hours researching this and the answers/documentation are incomplete or conflicting.

Any assistance would be appreciated.

@jmtphplist Once I had sorted out the permissions for the cache directory I had two php errors because of use of ReadOnly in one file

PHP Parse error: syntax error, unexpected token "readonly" in /home/duncan/www/lists_3.6.10/base/vendor/jms/serializer/src/JMS/Serializer/Metadata/Driver/AnnotationDriver.php on line 80

In php 8 readonly is a reserved keyword but as I’m running php 7.4 I don’t quite understand why it is hapening. Also don’t understand why it has not been picked up by the developer before.
If you change the two occurences of ReadOnly in the AnnotationDriver.php file to something else then the API should work.

Update - I was running php 8.1 on the web server but php 7.4 for the command line client, so the error now does make sense to me.

I have raised an issue with phplist API broken in release 3.6.10 · Issue #906 · phpList/phplist3 · GitHub

@duncanc - I am not seeing anything that indicates a permission problem.

Today, I started with a new manual install. I then changed the base/config/config_module.yml file changing false to true. There was no cache directory to delete.

I then ran this curl command:
curl --request POST --url http://my-domain.com/lists/api/v2/sessions --header ‘Content-Type: application/json’–data ‘{“login_name”: “yyyyy”,“password”: “xxxxxxxxxxxxx”}’

Note: my-domain, login-name value and password values were changed above from the actual values.

I got the following response
:
{“code”:400,“message”:“Empty JSON data”}
[1/2]: “login_name”: “yyyyy” →
curl–“login_name”: “yyyy”
curl: (6) Could not resolve host: “login_name”; Unknown error
[2/2]: “password”: “xxxxxxxxxxx” →
curl–“password”: “xxxxxxxxxxxxxx”
curl: (6) Could not resolve host: “password”; Unknown error

There are no errors in the error_log.

After running the curl command the base/var/cache directory was present. It and all of its sub directories have the same permissions:
drwxr-xr-x 3 zzzzz zzzzz 4096 Nov 7 10:48 cache/

Update: I changed the ReadOnly references you suggested even though I never saw the error entries in the error_log and there was no change in the results.

Second update: It turns out that the curl command had a syntax error. There was a space missing before the “–data”. That error exists in the document at API and integrations | phpList manual so if someone copy pastes the example curl command they will experience the same errors I did.

@jmtphplist So it is working now? The “readonly” problem would appear only if you are using php 8.1.

Yes, at least the example CURL worked. Now I am researching the endpoints. What I want to do is add a subscriber and then associate them with one or more lists. I see the endpoint to add a subscriber but I haven’t found where to assign a subscriber to a list.