-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X-Total-Pages header not (always) set #1
Comments
Got the same issue with version 2.4.0 when I call:
When I change this:
into (for testing)
The code continues, but breaks on: With the error : I'm using 0.12.0 of listmonk api |
It looks like Listmonk made some API changes:
The API returns now the number of pages:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
thanks for your work! Unfortunately I got an error while trying to use the api wrapper.
Environment
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?).
The text was updated successfully, but these errors were encountered: