Skip to content

Conversation

@samrajcse
Copy link

@samrajcse samrajcse commented Oct 1, 2018

fixes #233 ??
I would like to paginate the content based in skiptoken and not with pagination object. I do pagiantion on demand. So i need the option to pass the skiptoken as like top paramter. So added the option to add skiptoken in the reuest.

Now I can do like this to paginate.

Sample code:

do {

			List<? extends Option> requestOptions = new ArrayList<>();
			graphClient.users(userAccount).drive().root().children("").buildRequest(requestOptions);
			IDriveItemCollectionPage rootItems = graphClient.users(userAccount).drive().root().children().buildRequest().top(5).skipToken(skipToken).get();
			List<DriveItem> root = new ArrayList<>();
			root = rootItems.getCurrentPage();
			IDriveItemCollectionRequestBuilder iDriveItemCollectionRequestBuilder = rootItems.getNextPage();
			if (iDriveItemCollectionRequestBuilder != null) {
				String nextRequestUrl = iDriveItemCollectionRequestBuilder.getRequestUrl();
				System.out.println("Next page Request url : " + nextRequestUrl);
				if (StringUtils.isNotBlank(nextRequestUrl)) {
					skipToken = StringUtils.substringAfterLast(nextRequestUrl, "skiptoken=");
				}

			} else {
				skipToken = null;
			}

			for (DriveItem driveItem : root) {
				System.out.println("##########");
				System.out.println("ID : " + driveItem.id);
				System.out.println("NAME : " + driveItem.name);
				if (driveItem.file != null) {
					System.out.println("TYPE : File");

				} else {
					System.out.println("TYPE : Folder");

				};
			}
		} while (StringUtils.isNotBlank(skipToken));

From the documentation, the paginating the file using callback won't work in the standalone program. We need to pass the skip token based on the new request. So added the skip token functionality.
Adding skip token option for pagination
@msftclas
Copy link

msftclas commented Oct 1, 2018

CLA assistant check
All CLA requirements met.

@deepak2016 deepak2016 self-requested a review October 23, 2018 11:26
@baywet baywet self-assigned this Aug 17, 2020
@github-actions
Copy link
Contributor

This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.

@baywet baywet added this to the 2.0.1 milestone Sep 1, 2020
@baywet baywet removed the request for review from deepak2016 September 2, 2020 12:11
@baywet
Copy link
Member

baywet commented Sep 2, 2020

Thank you immensely for the pull request and for your patience.
Unfortunately I can't merge your pull request as is as this section of the code is generated, but it was really helpful identifying the issue and coming up with a solution.
You can see the result of the fixed code generation here #443
You can see the changes in the code generation process here microsoftgraph/MSGraph-SDK-Code-Generator#280
I also added the skip method which was missing.
Closing.

@baywet baywet closed this Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skiptoken methods are not available for pagination

3 participants