Skip to content

Commit 5eaa12b

Browse files
author
Sebastien.Dangelo
committed
Improve Retrieve Data Extension Row using the REST API to have max_rows
1 parent 1bc09e0 commit 5eaa12b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

FuelSDKWrapper.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def get_data_extension_columns(self, customer_key, property_list=None):
448448
def get_list_subscriber(self, search_filter=None, property_list=None):
449449
return self.get_objects(ObjectType.LIST_SUBSCRIBER, search_filter, property_list)
450450

451-
def get_data_extension_rows_rest(self, customer_key, search_filter=None, property_list=None, order_by=None, page_size=None, page=None):
451+
def get_data_extension_rows_rest(self, customer_key, search_filter=None, property_list=None, order_by=None, page_size=None, page=None, max_rows=2500):
452452
headers = {'content-type': 'application/json', 'Authorization': 'Bearer {}'.format(self.client.authToken)}
453453
endpoint = "{}data/v1/customobjectdata/key/{}/rowset?".format(self.client.base_api_url, customer_key)
454454

@@ -467,15 +467,19 @@ def get_data_extension_rows_rest(self, customer_key, search_filter=None, propert
467467
if page:
468468
endpoint += "&$page={}".format(page)
469469

470+
if max_rows < 0:
471+
max_rows = 2500
472+
470473
result = []
471474
r = requests.get(endpoint, headers=headers)
472475
if r.status_code == 200 and r.json()['count']:
473-
result = r.json()['items']
474-
while 'next' in r.json()['links']:
475-
endpoint = '{}data{}'.format(self.client.base_api_url, r.json()['links']['next'])
476-
r = requests.get(endpoint, headers=headers)
477-
if r.status_code == 200 and r.json()['count']:
478-
result += r.json()['items']
476+
result = r.json()['items'][:max_rows]
477+
if not page:
478+
while 'next' in r.json()['links'] and len(result) < max_rows:
479+
endpoint = '{}data{}'.format(self.client.base_api_url, r.json()['links']['next'])
480+
r = requests.get(endpoint, headers=headers)
481+
if r.status_code == 200 and r.json()['count']:
482+
result += r.json()['items'][:max_rows-len(result)]
479483
return result
480484

481485
def get_data_extension_rows(self, customer_key, search_filter=None, property_list=None):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy