Pagination Google .net Client library 3

Please Share

Google Developers

What is pagination?

Pagination has long been an issue for me in the Google .net client Library. When the number of results returned by your request is greater then the max results you need to use nextlink in order to get the next set of results.

This has lead to a number of strange hacks for me in the past. We now have an end to that.

I am going to show you a quick example of how this works. It will work with all of the Google APIs and the Google .net Client library, on any method that contains a nextlink and might need pagination. It can be a little tricky getting it to work and setting it up if you have any issues with your favorite API let me know I will see if i can build you an example.

The Code

This is a quick example using the Google Drive API V2.

Note: You are still making additional request to get the next page so watch your quota.

My Thanks

I would like to thank Jon Skeet for his efforts in adding pagination to the client library. You can read my feature request here. pagination #632

Please Share

Linda Lawton

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a Reply to Andreas Geier Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 thoughts on “Pagination Google .net Client library

    • Linda Lawton
      Linda Lawton Post author

      PageStreamer if memory serves is part of Google.Apis and yes if you import any of the API NuGet packages they will automatically grab Google.APIs (Google.Apis.Drive.V2 || Google.Apis.Drive.V3).

      Yes it was release a while ago one of those stealth releases that the team is becoming very good at. I really need to get on them about creating actual change log release announcements.

      Note: If you are running a project with Framework 4.0 then you probably wont have this it was probably released some where around version 1.12 and support for Framework 4.0 stopped at 1.10. In that case yes you can just grab the PageStreamer method and add it to your project manually it “should” work.

  • Andreas Geier

    Hi Linda,
    thank you very much for your Pagination Solution. I found your article and started to use it immediatly. It works perfect for me now. I use the Calendar API v3 and I face one problem:
    I do a full sync of all Events of a particular google calendar with about 7000 entries to a SQL-Server-Database.
    After I received the last entry, I expect to get also the “nextSyncToken” Property in the eventsList-Result.
    But it is always null.
    Any toughts?
    Thanks in advance.
    Kind regards