开发者

Get revision feed for a document in Google Docs using .NET

开发者 https://www.devze.com 2023-03-09 02:16 出处:网络
I am trying to get revision feed for an existing document in Google Docs (actually I just need revision count). I use the code below and get a GDataRequestException. The inner exception is 404 while t

I am trying to get revision feed for an existing document in Google Docs (actually I just need revision count). I use the code below and get a GDataRequestException. The inner exception is 404 while the response string is (document id is truncated):

<errors xmlns='http://schemas.google.com/g/2005'>
  <error>
    <domain>GData</domain>
    开发者_如何转开发<code>ResourceNotFoundException</code>
    <internalReason>Invalid document id: file:0BxwzFL2fD0</internalReason>
  </error>
</errors>

And here is the code:

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);


It looks like the resourceId you are using is invalid. Instead of constructing the uri manually, you should use the RevisionDocument property of the DocumentEntry instance you want to retrieve the revisions for:

var uri = entry.RevisionDocument;


var documentsRequest = new DocumentsRequest();

// ... do any authentication here..

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号