On 2/24/22 18:21, chucka@blackforest-co.com wrote:
I have this working:
#!/bin/bash H="http://lists.mysite.org/admin.cgi/newsletter-mysite.org/members" case $1 in 'add') curl "$H/add?subscribees=$2&adminpw=verysecret" ;; 'del') curl "$H/del?subscribees=$2&adminpw=verysecret" ;; esac
and scan the return for "Successfully [Un]subscribed"
Since the above is MM 2.1 I'm assuming you are asking how to do the above in MM 3 via REST. Here are some examples:
To add a single user
curl -urestadmin:restpass
--request POST
-H 'Content-Type: application/json'
--data-binary '{"list_id": "list.example.com",
"subscriber": "user@example.net",
"display_name": "Joe User",
"pre_verified": true,
"pre_confirmed": true,
"pre_approved": true}'
http://localhost:8001/3.1/members
Response is empty or a JSON object describing the error.
To delete a single user:
curl -urestadmin:restpass
--request DELETE
http://localhost:8001/3.1/lists/list.example.com/member/user@example.net
Response as above
To delete a list of users:
curl -urestadmin:restpass
--request DELETE
-H 'Content-Type: application/json'
--data-binary '{"emails": ["user@example.net","other@example.org"]}'
http://localhost:8001/3.1/lists/list.example.com/roster/member
Response is a JSON object similar to
{"user@example.net": true, "other@example.org": false, "http_etag": "\"...\""}
where success or failure is indicated by a true or false value for each address or a JSON object describing the error if any.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan