发现 API 失败,出现 JSON 错误

Discovery API failing with JSON error

我有一个非常简单的程序,旨在使用 Google Discovery API。但是,当我尝试使用 getRest 调用时,它失败了,如下所示。有任何想法吗?我使用的是来自 NuGet、VS 2012 Pro 的 Discovery API 的最新版本。

DiscoveryService service = new DiscoveryService(new Google.Apis.Services.BaseClientService.Initializer());

//this works no problem
service.Apis.List().Execute();

//this works on the API reference page's Try It! area, but fails here
service.Apis.GetRest("admin", "directory_v1").Execute();

这是在 Google.Apis.Requests.ClientServiceRequest class 的 Execute() 方法中引发的结果错误 - 第 96 行:

JsonSerializationException was unhandled

Additional content found in JSON reference object. A JSON reference object should only have a $ref property. Path 'schemas.User.properties.name.description', line 1251, position 20.

这是记录在案的错误。 Get the generated discovery to discovery its own discovery document #79

我目前找到的唯一解决方法是使用客户端库登录,然后从 Discovery API 手动发出我的请求。它很乱而且不能很好地工作,因为你可以使用 Discovery API class 库会给你的 class 结构。