From d4a316019ddda795cc3cf66f7993f49a740628dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Willi=20M=C3=BCller?= Date: Mon, 19 Feb 2024 15:40:31 +0100 Subject: [PATCH] Rest API: Ends pagination if next page path is not in response.json() (#361) --- sources/rest_api/paginators.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sources/rest_api/paginators.py b/sources/rest_api/paginators.py index f0d9ffa42..e63754e85 100644 --- a/sources/rest_api/paginators.py +++ b/sources/rest_api/paginators.py @@ -182,7 +182,10 @@ def __init__( self._records_accessor = create_nested_accessor(records_key) def update_state(self, response: Response): - self.next_reference = self._next_key_accessor(response.json()) + try: + self.next_reference = self._next_key_accessor(response.json()) + except KeyError: + self.next_reference = None def extract_records(self, response: Response) -> Any: return self._records_accessor(response.json())