Git Product home page Git Product logo

listmonk-api's People

Contributors

knucklessg1 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

listmonk-api's Issues

X-Total-Pages header not (always) set

Hey,
thanks for your work! Unfortunately I got an error while trying to use the api wrapper.

Environment

  • listmonk v2.3.0 in docker behind a nginx-reverse proxy with a single list and a single subscriber
  • python script on remote computer using this api in version 0.1.2

Code
lm_client = listmonk_api.Api(url=listmonk_api_url, username=username, password=password) print(f"Subscribers: {lm_client.get_subscribers()}")

Error
Traceback (most recent call last): File "/home/random/repositories/test/files.py", line 22, in <module> print(f"Subscribers: {lm_client.get_subscribers()}") File "/home/random/repositories/test/.venv/lib/python3.10/site-packages/listmonk_api/decorators.py", line 19, in wrapper return function(self, *args, **kwargs) File "/home/random/repositories/test/.venv/lib/python3.10/site-packages/listmonk_api/listmonk_api.py", line 65, in get_subscribers total_pages = int(response.headers['X-Total-Pages']) File "/home/random/repositories/test/.venv/lib/python3.10/site-packages/requests/structures.py", line 52, in __getitem__ return self._store[key.lower()][1] KeyError: 'x-total-pages'

At first I thought it may be caused by the nginx dropping an empty header, but even a local request from inside the container isn't containg an 'X-Total-Pages'-header.

A possible solution could be to fall back to 1 if the header doesn't exist (seems to be the case if the response isn't paged at all?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.