msgraph-sdk-python-core icon indicating copy to clipboard operation
msgraph-sdk-python-core copied to clipboard

Developers should be able to consumed paged collections easily (Page iterator support)

Open roinochieng opened this issue 3 years ago • 1 comments

AB#13319

For a variety of reasons, collections of entities are often split into pages and each page is returned with a URL to the next page. Sometimes, page granularity provided by the API does not match the requirements of the consumer. This task aims to simplify the life of consumers of paged collections through implementing the page iterator.

Design requirements and specifications here

roinochieng avatar Mar 14 '22 12:03 roinochieng

would love to see such a feature, either as an iterator or as an optional argument for the requesting function!

edit: meanwhile, my workaround for collecting all the data (does not respect any memory limitations etc.)

client = GraphClient(...)
results = [client.get('/users')]
# Handle Next Link
while results[-1].json().get('@odata.nextLink'):
    page_result = client.get(results[-1].json().get('@odata.nextLink'))
    results.append(page_result)

basti95 avatar Mar 28 '22 14:03 basti95

@shemogumbe to close this issue and link it to the closed PR.

sebastienlevert avatar Mar 27 '24 15:03 sebastienlevert

thanks for reporting this issue, we have since released a new version of the SDK which this issue doesn't apply to. We encourage you to migrate to the new version and open a new issue if you still need help

baywet avatar Apr 25 '24 15:04 baywet