C# 如何防止google日历请求接收google联系人响应

C# 如何防止google日历请求接收google联系人响应,c#,google-calendar-api,google-api-client,google-api-dotnet-client,C#,Google Calendar Api,Google Api Client,Google Api Dotnet Client,多年来,我们通过c#客户端库(Google.API.Calendar.v3.1.9.2.1330)成功地使用了Google联系人和日历API。最近发生了一个不寻常的错误。日历API调用似乎得到了联系API响应(见下文)。以前有没有人遇到过这种情况,并且有办法防止这种情况再次发生 编辑: 包括代码段: using Google.Apis.Calendar.v3; using Google.Apis.Calendar.v3.Data; using Google.Apis.Http; using Go

多年来,我们通过c#客户端库(Google.API.Calendar.v3.1.9.2.1330)成功地使用了Google联系人和日历API。最近发生了一个不寻常的错误。日历API调用似乎得到了联系API响应(见下文)。以前有没有人遇到过这种情况,并且有办法防止这种情况再次发生

编辑: 包括代码段:

using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Http;
using Google.Apis.Services;

...

var eventList = service.Events.List(calendarListEntry.Id);
eventList.TimeMin = dateFrom;
eventList.TimeMax = dateTo;
eventList.SingleEvents = true;
var events = eventList.Execute().Items;

编辑:这里有一个这样的例子。我从日志中提取了任何敏感信息,但事件的顺序是。1.我们看到两个成功的API请求和响应。2.我们得到一个404响应,但奇怪的是,它导致了一个解析异常,好像响应包含xml或至少以“您是否可以发布代码”开头的内容,看起来您试图混合xml和Json。Calendar V3返回JSon联系人API是一个旧的gdata API,返回xml。默认情况下,它们可能无法很好地配合。您好,DalmTo,是的,会引发异常,因为响应是属于另一个线程的json联系人响应,但不清楚日历api客户端调用为什么会收到该响应。我在问题中包含了异常发生的行(var events=eventList.Execute().Items;)。谢谢你的帮助,让我们来看看你的一些代码。这不会返回那个错误。我需要导致错误的代码。当前的google.net客户端库不与旧的gData api通信,它们是两个不同的系统。请输出calendarListEntry.IdImportGmailCalendarService.cs的值:第59行==“var events=eventList.Execute().Items;”
1.
    "63577099854207364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer xxx, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer xxx
    , Thread50"
    "63577099854637364450, Request https://www.googleapis.com/calendar/v3/calendars/eaxmple@domain.com/events?singleEvents=True&timeMax=2016-03-06T01:30:53.873Z&timeMin=2016-02-05T01:30:53.873Z, req auth:Bearer xxx, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer xxx
    , Thread50"
    "63577099854207364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer xxx, Thread41, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:54 GMT
      Server: GSE
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:54 GMT
    }"
    "63577099854637364450, Request https://www.googleapis.com/calendar/v3/calendars/eaxmple@domain.com/events?singleEvents=True&timeMax=2016-03-06T01:30:53.873Z&timeMin=2016-02-05T01:30:53.873Z, req **auth:Bearer xxx**, Thread29, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:54 GMT
      Server: **GSE**
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:54 GMT
    }"
    "63577099856222364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer yyy
    , Thread50"
2.    "63577099856222364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req **auth:Bearer yyy**, Thread42, result:StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Connection: close
      Date: Sun, 06 Sep 2015 01:30:56 GMT
      Server: **GFE/2.0**
      Content-Length: 1527
      Content-Type: text/html; charset=UTF-8
    }"
    An Error occurred, but the error response could not be deserialized|The service calendar has thrown an exception: Google.GoogleApiException: An Error occurred, but the error response could not be deserialized ---> Newtonsoft.Json.JsonReaderException: **Unexpected character encountered while parsing value: <.** Path '', line 0, position 0.
       at Newtonsoft.Json.JsonTextReader.ParseValue()
       at Newtonsoft.Json.JsonTextReader.ReadInternal()
       at Newtonsoft.Json.JsonTextReader.Read()
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
       at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
       at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
       at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
       at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
       at Google.Apis.Json.NewtonsoftJsonSerializer.Deserialize[T](String input) in c:\ApiaryDotnet\default\Src\GoogleApis.Core\Apis\Json\NewtonsoftJsonSerializer.cs:line 120
       at Google.Apis.Services.BaseClientService.<DeserializeError>d__8.MoveNext() in c:\ApiaryDotnet\default\Src\GoogleApis\Apis\Services\BaseClientService.cs:line 286
       --- End of inner exception stack trace ---
       at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\ApiaryDotnet\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 102
       at DataIntegration.Services.Google.ImportGmailCalenderService.ImportGmailCalendars(DateTime dateFrom, DateTime dateTo, Boolean validateResultsAreForCorrectAccount, ISet`1 internalDomainUrls, String email, String account) in c:\buildworkspaces\WebApp-BuildUnitTest-NextRelease\NextRelease\DataIntegration\Services\Google\ImportGmailCalendarService.cs:line 59


3.    "63577099858032364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, headers:User-Agent: Datahug google-api-dotnet-client/1.9.3.19379 (gzip)
    Authorization: Bearer yyy
    , Thread50"
    "63577099858032364450, Request https://www.googleapis.com/calendar/v3/users/me/calendarList, req auth:Bearer yyy, Thread39, result:StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Vary: Origin
      Vary: X-Origin
      X-Content-Type-Options: nosniff
      X-Frame-Options: SAMEORIGIN
      X-XSS-Protection: 1; mode=block
      Alternate-Protocol: 443:quic,p=1
      Alt-Svc: quic="":443""; p=""1""; ma=604800
      Transfer-Encoding: chunked
      Cache-Control: no-transform, must-revalidate, max-age=0, private
      Date: Sun, 06 Sep 2015 01:30:58 GMT
      Server: GSE
      Content-Type: application/json; charset=UTF-8
      Expires: Sun, 06 Sep 2015 01:30:58 GMT
    }"