Python

Discussion in 'General discussions' started by Eric535, Oct 30, 2019.

  1. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    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?
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,436
    Likes Received:
    2,427
    Eric535 likes this.
  3. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
  4. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    @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:

    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)
     
  5. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    22
    Likes Received:
    8
    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
    
     
  6. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,436
    Likes Received:
    2,427
    You have options for this, you can select which area to check: import, export, list subscribe, etc.
     
    Eric535 likes this.
  7. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    @ghimes I did. I used the documentation from the link below.

    https://pypi.org/project/mailwizz-python-sdk/
     
  8. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,436
    Likes Received:
    2,427
    @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.
     
    Eric535 likes this.
  9. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    Thats awesome :)
    @twisted1919 Is @ghimes The Python guy? :)
     
  10. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    22
    Likes Received:
    8
    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
     
    Eric535 likes this.
  11. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    22
    Likes Received:
    8
    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 likes this.
  12. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    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
     
  13. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    22
    Likes Received:
    8
    Hello,
    That is fine. Disable signature checking from Mailwizz. This something that we need to discuss (me and @twisted1919 ).
    Cosmin
     
    Eric535 likes this.
  14. Eric535

    Eric535 Member

    Joined:
    Sep 22, 2016
    Messages:
    314
    Likes Received:
    16
    S.E:
    2020-04-07 11:56:57
    L.T:
    Regular
    L.C:
    6
    I disabled it and it worked. Thanks :)
     
    twisted1919 likes this.

Share This Page