VingtCinq / python-mailchimp

Python client for v3 of MailChimp API
MIT License
463 stars 131 forks source link

'MailChimpError' object is not subscriptable #219

Open miguoliang opened 4 years ago

miguoliang commented 4 years ago
    try:
        members = client.lists.members.create('xxxxxx', {
            'email_address': 'example@123.com,
            'status': 'subscribed'
        })
    except MailChimpError as e:
        print(e['status'])
    return {
        'status': 200
    }

I run the above code, it should raise a MailChimpError exception, but when I try to read the property status, I got a new exception that 'MailChimpError' object is not subscriptable.

How can I fix it?

michaelwalkerfl commented 4 years ago

If you update your code to print(e[0]['status']) it will return the status code you desire without an error.

ghost commented 4 years ago

I have similar code if I do the e[0]["status"] think it just says "TypeError: 'MailChimpError' object does not support indexing" instead.

marcomayer commented 4 years ago

I did run into the same issue, surely is broken currently. Workaround: print(e.args[0].get("status"))

ghost commented 4 years ago

I have the same issue. Using 3.0.14

Jake-Mulhern commented 2 years ago

I am running into the same issue. Has a solution to this been implemented?