使用.NET获取Google Docs中文档的修订Feed

时间:2011-05-30 17:13:09

标签: c# .net google-api google-docs google-docs-api

我正在尝试在Google文档中获取现有文档的修订Feed(实际上我只需要修订计数)。我使用下面的代码获得GDataRequestException。内部异常是404,而响应字符串是(文档id被截断):

<errors xmlns='http://schemas.google.com/g/2005'>
  <error>
    <domain>GData</domain>
    <code>ResourceNotFoundException</code>
    <internalReason>Invalid document id: file:0BxwzFL2fD0</internalReason>
  </error>
</errors>

以下是代码:

var documentsService = new DocumentsService("myappname");
documentsService.SetAuthenticationToken(token);

var uri = string.Format("https://docs.google.com/feeds/default/private/full/{0}/revisions", Uri.EscapeDataString(resourceId));
var query = new DocumentsListQuery(uri);
var feed = documentsService.Query(query);

2 个答案:

答案 0 :(得分:0)

看起来您使用的resourceId无效。 您应该使用要检索修订版的DocumentEntry实例的RevisionDocument属性,而不是手动构建uri:

var uri = entry.RevisionDocument;

答案 1 :(得分:0)

var documentsRequest = new DocumentsRequest();

// ... do any authentication here..

var revisions = documentsRequest.Get<Google.Documents.Document>(entry.RevisionDocument).Entries;