Google Plus API Moment.Insert [英] Google Plus API Moment.Insert
问题描述
我正在尝试使用google-api-dotnet-client插入moment.insert,并且还在oauth请求中包含了request_visible_actions和access_type,但是我总是遇到异常:
I am trying for moment.insert using google-api-dotnet-client and also included the request_visible_actions and access_type in oauth request but I am always getting exception:
字典中不存在给定的键.
这是堆栈跟踪:
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Google.Apis.Discovery.BaseService.GetResource(IResource root, String fullResourceName) in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Discovery\Service.cs:line 279
at Google.Apis.Discovery.BaseService.CreateRequest(String resource, String methodName) in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Discovery\Service.cs:line 186
at Plus.v1.PlusService.CreateRequest(String resource, String method)
at Google.Apis.Requests.ServiceRequest`1.BuildRequest() in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 134
at Google.Apis.Requests.ServiceRequest`1.GetAsyncResponse(Action`1 responseHandler) in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 169
at Google.Apis.Requests.ServiceRequest`1.GetResponse() in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 185
at Google.Apis.Requests.ServiceRequest`1.Fetch() in c:\code.google.com\google-api-dotnet-client\default\Tools\BuildRelease\bin\Debug\12-20-2012\default\Src\GoogleApis\Apis\Requests\ServiceRequest.cs:line 211
at VocalbeeWebApp.Controllers.HomeController.CheckGooglePlusAuthorization() in d:\Projects\VocalBee\VocalBeeSocialServer-T\VocalbeeWebApp\VocalbeeWebApp\Controllers\HomeController.cs:line 217
下面是moment.insert的代码段:
Below is the code snippet for moment.insert:
Google.Apis.Plus.v1.Data.Moment body = new Google.Apis.Plus.v1.Data.Moment();
Google.Apis.Plus.v1.Data.ItemScope target = new Google.Apis.Plus.v1.Data.ItemScope();
target.Id = "target-id";
target.Image = "http://www.vocalbee.com/Images/WebLogoNewSmall.png";
target.Type = "http://schemas.google.com/AddActivity";
target.Description = "The description for the activity";
target.Name = "An example of add activity";
body.Target = target;
body.Type = "http://schemas.google.com/AddActivity";
Google.Apis.Plus.v1.MomentsResource.InsertRequest insert =
new Google.Apis.Plus.v1.MomentsResource.InsertRequest(
pw.plusService,
body,
me.Id,
Google.Apis.Plus.v1.MomentsResource.Collection.Vault);
Google.Apis.Plus.v1.Data.Moment result = insert.Fetch();
有人可以帮助我解决问题吗?
Can anybody help me in figuring out the problem?
推荐答案
您似乎正在使用旧版本的库.最新版本可从此处获得:
It looks like you might be using an older version of the library. The latest version is available from here:
- Google+ Downloads
- Google+ .NET client library
请确保将所有较旧的客户端库依赖项替换为较新的客户端库依赖项.您至少应替换以下版本的现有版本:
Make sure that you replace all of the older client library dependencies with the newer ones. You should at least replace existing versions of:
- Google.Apis.dll
- Google.Apis.Plus.v1.dll
这篇关于Google Plus API Moment.Insert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!