2nd follow-up. Apologies for spamming this list.
I went wandering through the code as suggested by the traceback. I discovered that thee "as_boolean" routine is expecting a string argument but getting a boolean argument.
So, If I send the booleans as strings, with values "true" or "false", all is well. This is not what the API documentation suggests I should do. Can someone either fix the documentation or the code?
Thanks
-- Stephen
On Tue, Jan 18, 2022 at 1:44 PM Stephen Daniel <swd@pobox.com> wrote:
Followup note: The failed post is associated with this message in mailman.log:
2022-01-18 13:01:49 [FALCON] [ERROR] POST /3.1/members => Traceback (most recent call last): File "falcon/app.py", line 361, in falcon.app.App.__call__ File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailman/rest/members.py", line 302, in on_post arguments = validator(request) File "/opt/mailman/mm/venv/lib/python3.7/site-packages/mailman/rest/validator.py", line 227, in __call__ values[key] = self._converterskey File "/opt/mailman/mm/venv/lib/python3.7/site-packages/lazr/config/_config.py", line 762, in as_boolean value = value.lower() AttributeError: 'bool' object has no attribute 'lower'
Possible bug in code?
On Tue, Jan 18, 2022 at 1:22 PM Stephen Daniel <swd@pobox.com> wrote:
Mailman3 experts --
I am trying to subscribe a user to a mailing list via the REST API. This works:
Posting to url http://localhost:8001/3.1/members POST payload: { "list_id": "<LISTID>", "subscriber": "d13b0bbb29844eb9af4b38dad7bb3707", } RESULT post of "http://localhost:8001/3.1/members" succeeds with code 202
This works does *not *work
Posting to url http://localhost:8001/3.1/members POST payload: { "list_id": "<LISTID>", "subscriber": "d13b0bbb29844eb9af4b38dad7bb3707", "pre_approved": true } RESULT post of "http://localhost:8001/3.1/members" fails with code 500
Any suggestions? As best I can tell, inclusion of *any* boolean types in my JSON causes the error code 500. FWIW I am generating the JSON using go language's JSON package.
I noticed in the API doc that the boolean values are represented as 'True' rather than 'true'. So I tried converting all instances of 'true' to 'True' in my encoded json. That produced an http 400 error, as it probably should.
Thanks!
-- Stephen