How can I get a Google Document's Description?
-
08-06-2021 - |
Question
The Goal
Say I have a collection/folder of documents in Google Docs/Drive, and I want to programmatically retrieve the Description associated with each:
(You get this by selecting the file in the list, then hitting the "eye" icon)
The Working Code
I am using the .NET library for the Google Data API and have the basic login and retrieval working without issue:
GDataCredentials credentials = BuildSomethingUp();
RequestSettings settings
= new RequestSettings("code.google.com/p/exult/", credentials);
Request request = new Request(settings);
Feed<Document> feed = request.GetFolderContent(resourceId);
List<Document> documents = feed.Entries.ToList();
foreach (Document document in documents
.Where(item => item.Type != Document.DocumentType.Folder))
{
string summary = document.Summary; //y no can haz?
}
However, the .Summary
property always comes back as null.
The Question(s)
- I was working on the assumption that
.Summary
was the correct location based on some deprecated code sections, etc. Is this a bogus assumption? - How else might I retrieve the description associated with the document? ("I can haz dezcryption?" in the ludicrous example above)
Solution
The .NET client library didn't expose that field, I just committed some code in rev. 1189 (http://code.google.com/p/google-gdata/source/detail?r=1189) that adds a Description property to the DocumentEntry class. You can now access the description with the following code:
string description = document.DocumentEntry.Description;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow