Question

I'm using the mailjet Python API, and I'm a little confused.

https://www.mailjet.com/docs/api/lists/contacts

It doesn't even appear possible to use this API class to call mailjets GET methods. Can anyone confirm this is the case?

api.lists.Contacts(id='foo') # causes POST, thus 405

Here's their API classes. I don't even see ApiMethodFunction passing options to the connection class.

class ApiMethod(object):
    def __init__(self, api, method):
        self.api = api
        self.method = method

    def __getattr__(self, function):
        return ApiMethodFunction(self, function)

    def __unicode__(self):
        return self.method

class ApiMethodFunction(object):
    def __init__(self, method, function):
        self.method = method
        self.function = function

    def __call__(self, **kwargs):
        response = self.method.api.connection.open(
            self.method,
            self.function,
            postdata=kwargs,
        )
        return json.load(response)

    def __unicode__(self):
        return self.function

It seems like a critical feature so I'm inclined to think I'm just using it incorrectly, but could it be?

How are you supposed to list Contacts if it needs id in the GET parameters?

Was it helpful?

Solution

the python library is now fixed. According to its author, you can now pass a parameter to specify if the request is going to be a POST or a GET

https://github.com/WoLpH/mailjet

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top