Skip to content

Need option to paginate the results based on skiptoken parameter - #148

Closed
Samraj (samrajcse) wants to merge 2 commits into
microsoftgraph:devfrom
samrajcse:dev
Closed

Need option to paginate the results based on skiptoken parameter#148
Samraj (samrajcse) wants to merge 2 commits into
microsoftgraph:devfrom
samrajcse:dev

Conversation

@samrajcse

@samrajcse Samraj (samrajcse) commented Oct 1, 2018

Copy link
Copy Markdown

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

Microsoft Contribution License Agreements (msftclas) commented Oct 1, 2018

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@github-actions

Copy link
Copy Markdown
Contributor

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

@baywet

Copy link
Copy Markdown
Member

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.

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