Limited number of rows returned from Google spreadsheet and the Sheets Api

543 Views Asked by At

I have a spreadsheet on Google Drive with 571 rows that I read from an other application. I call it using the Google.GData.Spreadsheets 2.2.0 lib and the following piece of simplified code.

    static void Main(string[] args)
    {
        var certificate = new X509Certificate2("Key.p12", "blahblah", X509KeyStorageFlags.Exportable);

        const string user = "[email protected]";

        var serviceAccountCredentialInitializer =
           new ServiceAccountCredential.Initializer(user)
           {
               Scopes = new[] { "https://spreadsheets.google.com/feeds" }
           }.FromCertificate(certificate);

        var credential = new ServiceAccountCredential(serviceAccountCredentialInitializer);

        if (!credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Result)
            throw new InvalidOperationException("Access token request failed.");

        var requestFactory = new GDataRequestFactory(null);
        requestFactory.CustomHeaders.Add("Authorization: Bearer " + credential.Token.AccessToken);

        var service = new SpreadsheetsService(null) { RequestFactory = requestFactory };

        var query = new ListQuery("https://spreadsheets.google.com/feeds/list/blahblah/1/private/full") ;

        var feed = service.Query(query);

        // Not all rows 571 rows are returned. Only 369 feed.Entries !?
    }

My problem is that even if I have 571 rows in the document I only receive the first 369 entries back - why is that? Is there a limitation in the api for how many rows a spreadsheet can return? If so, how should I handle that?

I've double checked and the uri points to the right spreadsheet document and all the rows are on the first sheet of the document. It actually looks like the even a ordinary http get to https://spreadsheets.google.com/feeds/list/blahblah/1/private/full doesn't return all the rows?

What am I missing here?

1

There are 1 best solutions below

0
On BEST ANSWER

Turned out that I had an empty row in the sheet and the API won't read new rows after that.