Python

Eric535

Member
For the past few weeks I been learning python and automating alot of my tasks.

I want to automate some of my mailwizz tasks as well. I want to be able to add subscribers to lists using python and the mailwizz api instead of importing lists.

I went to the link below.
https://pypi.org/project/mailwizz-python-sdk/

There is a link their pointing back to mailwizz site for the documentation but the link is broken...

https://api-docs.mailwizz.com/python

Is python no longer an option?
 

Eric535

Member
@twisted1919 So i downloaded the files and I created my API credentials. I inserted them into setup_api.py. But when I run a "GET ALL SUBSCRIBERS OF A LIST" which I grabbed from your examples, I get the following error message:

Traceback (most recent call last):
File "/Users/eric/Dropbox/python/mailwizz/mailwizz-python-sdk-master/examples/geta_all_subscribers_from_a_list.py", line 17, in <module>
response = endpoint.get_subscribers(list_uid='nt518m8hv9804', page=1, per_page=10)
File "../mailwizz/endpoint/list_subscribers.py", line 21, in get_subscribers
'url': self.config.get_api_url('lists/{list_uid}/subscribers'.format(list_uid=list_uid)),
AttributeError: 'dict' object has no attribute 'get_api_url'
[Finished in 0.3s with exit code 1]
[shell_cmd: python3 -OO -u "/Users/eric/Dropbox/python/mailwizz/mailwizz-python-sdk-master/examples/geta_all_subscribers_from_a_list.py"]
[dir: /Users/eric/Dropbox/python/mailwizz/mailwizz-python-sdk-master/examples]
[path: /Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands]
Here is the code i'm using:

Code:
from setup_api import setup
from endpoint.list_subscribers import ListSubscribers

"""
SETUP THE API
"""
setup()

"""
CREATE THE ENDPOINT
"""
endpoint = ListSubscribers()

"""
GET ALL SUBSCRIBERS OF A LIST
"""
response = endpoint.get_subscribers(list_uid='nt518m8hv9804', page=1, per_page=10)

"""
DISPLAY RESPONSE
"""
print(response.content)
 

ghimes

Member
Staff member Support Staff
@Eric535 - I think we never got to actually write the docs for the python sdk, that's something @ghimes has to confirm.
No, we didn't write any documentation yet.

For the error above try:
Did you install the SDK using pip? Like this:
Code:
pip install mailwizz-python-sdk
 

twisted1919

Administrator
Staff member
@ghimes - maybe you can try running the sdk and see if it will work for you or not.
This might also be related to the python version, but since i don't really know python, i can't tell exactly.
 

ghimes

Member
Staff member Support Staff
Hello,
Not really, but I created this library. The problem you are having is because of the imports. Normally if mailwizz is installed with pip, you will not need to add 'mailwizz' in the imports path of each import. Please try this and let me know. Since you are learning Python, maybe in the future you will us improve this library since we are not python experts.
Example for your setup_api.py. But you should add mailwizz for each import related to the mailwizz SDK
Code:
from mailwizz.base import Base
from mailwizz.config import Config
examples/list_subscribers.py
Code:
from setup_api import setup
from mailwizz.endpoint.list_subscribers import ListSubscribers
Important! Since you already installed using pip, i suppose that near your example folder you have the mailwizz folder. Remove it or rename it, because the import system will try to use it.
Let me know how it went

Cosmin
 

ghimes

Member
Staff member Support Staff
Hello,
I did some changes for the examples in the git repo. I added the Mailwizz module as parent for all the related imports. Please take them and let me know. Also it shouldn't be a problem to have the mailwizz folder near.
Please let me know.
Cosmin
 

Eric535

Member
Hello,
I did some changes for the examples in the git repo. I added the Mailwizz module as parent for all the related imports. Please take them and let me know. Also it shouldn't be a problem to have the mailwizz folder near.
Please let me know.
Cosmin
So i downloaded the new files fro the github link. Now im getting an error:

b'{"status":"error","error":"Invalid API request signature. Please refer to the documentation."}'

Check out my snapshots.

Thanks for your help.

Screen Shot 2019-11-04 at 4.18.00 AM.jpg Screen Shot 2019-11-04 at 4.19.25 AM.jpg
 
Top