Reputation: 18961
So, the examples show you how to fetch a spreadsheet feed that gets ALL spreadsheets on the drive.
What is the format for setting the query.Uri? If i use entry.SelfUrl, or the following code, I get a 400 bad request
SpreadsheetQuery query = new SpreadsheetQuery();
query.Uri = new Uri(string.Format("{0}/{1}", DocumentsListQuery.documentsBaseUri, entry.ResourceId)); //400
// query.Uri = entry.SelfUri.Content; //also a 400
I also tried many different forms of the feed url, not least the one suggested by the one-page API documentation (replacing the key
with the ResourceId
, this actually returned a null feed, not a 400):
https://spreadsheets.google.com/feeds/worksheets/key/private/full
How do I fetch just one file?
Instead i am having to fetch all and query client-side:
var feed = SpreadsheetFeedFor(query);
var spreadsheet = (SpreadsheetEntry)feed.Entries.Single(e => e.SelfUri == resourceUri);
Upvotes: 3
Views: 2252
Reputation: 18961
So, what is a spreadsheet other than a collection of Worksheets? Not much apparently, nothing discrete from a spreadsheet perspective - something with a filename, and you get that with the Docs API...soo, to get a spreadsheet, I've used the sample code that gets the worksheets for a given spreadsheet (by its drive's ResourceId / key):
/// <summary>
/// fetch a worksheet feed for a given spreadsheet
/// </summary>
/// <param name="resourceId"></param>
/// <returns></returns>
protected WorksheetFeed WorksheetsFor(string resourceId)
{
var path = "https://spreadsheets.google.com/feeds/worksheets/{0}/private/full".Substitute(resourceId);
WorksheetQuery query = new WorksheetQuery(path);
WorksheetFeed feed = SpreadsheetsService.Query(query);
return feed;
}
Upvotes: 3