I am using Docker-mailman (GNU Mailman 3.2.0a1), but from the host I am trying to create a list using the REST API in the (yet, no offense) lack of a template for new list configurations.
I get a nice dictionary when getting data out of Mailman, but using this exact dictionary (for debug) as payload to Mailman (my mmapiwrite), and with reference to https://mailman.readthedocs.io/en/latest/src/mailman/rest/docs/lists.html#cr..., I get a response "A server error occurred. Please contact the administrator.".
I don't understand the dump_json and I find the docs above hard to follow. How should I create the list using REST?
<code> restapiversion = '3.1'
def getlistdefaultsx(): # Exact output from Mailman, see below. listdefaultsx = { 'acceptable_aliases': [], 'admin_immed_notify': True, 'admin_notify_mchanges': False, 'administrivia': True, [SNIP] 'subscription_policy': 'confirm_then_moderate', 'volume': 1}
return(listdefaultsx)
def get_all_list_names(): all_list_fqdn = [] response = mmapi('lists?count=10&page=1') output = response.json() for entry in output.get('entries'): all_list_fqdn.append(entry.get('fqdn_listname')) return(all_list_fqdn)
def addlist(): list_setup = getlistdefaultsx() go_create_list('abc', list_setup)
def go_create_list(list_name_fqdn, list_setup): #pprint(list_setup) print('Creating list %s ...' % list_name_fqdn) response = mmapiwrite('lists', list_setup)
def mmapi(apicommand): response = requests.get('http://172.19.199.2:8001/%s/%s' % (restapiversion, apicommand), auth=('restadmin', 'restpass'))
def mmapiwrite(apicommand,payload): response = requests.post('http://172.19.199.2:8001/%s/%s' % (restapiversion, apicommand), data=payload, auth=('restadmin', 'restpass'))
getlistdefaultsx is an actual dictionary with real output from Mailman using my mmapi from an existing test list (though domain names are masked. Of course I can't create an existing list, but when changing the list name I get the same error message.
{'acceptable_aliases': [], 'admin_immed_notify': True, 'admin_notify_mchanges': False, 'administrivia': True, 'advertised': True, 'allow_list_posts': True, 'anonymous_list': False, 'archive_policy': 'never', 'autorespond_owner': 'none', 'autorespond_postings': 'none', 'autorespond_requests': 'none', 'autoresponse_grace_period': '90d', 'autoresponse_owner_text': '', 'autoresponse_postings_text': '', 'autoresponse_request_text': '', 'bounces_address': 'hertest2-bounces@example.ku.dk', 'collapse_alternatives': True, 'convert_html_to_plaintext': False, 'created_at': '2018-03-19T14:19:49.018252', 'default_member_action': 'defer', 'default_nonmember_action': 'hold', 'description': 'Test-domæne for Mailman 3-testlister', 'digest_last_sent_at': None, 'digest_send_periodic': True, 'digest_size_threshold': 30.0, 'digest_volume_frequency': 'monthly', 'digests_enabled': True, 'display_name': 'Hertest2', 'dmarc_mitigate_action': 'no_mitigation', 'dmarc_mitigate_unconditionally': False, 'dmarc_moderation_notice': '', 'dmarc_wrapped_message_text': '', 'filter_content': False, 'first_strip_reply_to': False, 'fqdn_listname': 'hertest2@example.ku.dk', 'http_etag': '"987dfgf8g569fvfd6v7"', 'include_rfc2369_headers': True, 'info': '', 'join_address': 'hertest2-join@example.ku.dk', 'last_post_at': None, 'leave_address': 'hertest2-leave@example.ku.dk', 'list_name': 'hertest2', 'mail_host': 'example.ku.dk', 'max_message_size': 40, 'moderator_password': None, 'next_digest_number': 1, 'no_reply_address': 'noreply@example.ku.dk', 'owner_address': 'hertest2-owner@example.ku.dk', 'post_id': 1, 'posting_address': 'hertest2@example.ku.dk', 'posting_pipeline': 'default-posting-pipeline', 'reply_goes_to_list': 'no_munging', 'reply_to_address': '', 'request_address': 'hertest2-request@example.ku.dk', 'send_welcome_message': True, 'subject_prefix': '[Hertest2] ', 'subscription_policy': 'confirm_then_moderate', 'volume': 1} </code>