调用AdexchangebuyerService.Creatives.List时,Google.Apis.Adexchangebuyer.v13中的GoogleApiException

时间:2015-04-25 04:43:33

标签: c# google-api-dotnet-client

我在使用高数字(> 20)广告素材ID调用LIST时遇到此异常。使用大约10个广告素材调用LIST时,它可以正常工作,每次调用大约需要30秒。

以下是例外情况:

Google.GoogleApiException was caught HResult=-2146233088 Message=Google.Apis.Requests.RequestError Backend Error [500] Errors [ Message[Backend Error] Location[ - ] Reason[backendError] Domain[global] ]

Source=Google.Apis ServiceName=adexchangebuyer StackTrace: at Google.Apis.Requests.ClientServiceRequest`1.Execute() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:line 102 InnerException:

这是使用Google.Apis.AdExchangeBuyer.v1_3 1.9.0.48的调用代码:(我也尝试使用1.9.0.51)

    var listRequest = this.AdexchangebuyerService.Creatives.List();
    listRequest.MaxResults = 1000;
    listRequest.BuyerCreativeId = new Repeatable<string>(creativeIds ); 
    // creativeIds is IEnumerable<string>; (fails with 20 creative ids, passes with 10)
    var listOfCreatives = listRequest.Execute(); // -- exception thrown here

使用客户端库在fiddler中捕获的请求:

GET https://www.googleapis.com/adexchangebuyer/v1.3/creatives?key={YOUR_API_KEY}&pageToken=mypa‌​getoken&maxResults=1000&buyerCreativeId=i7bhb44u&buyerCreativeId=f5bfbul2 
HTTP/1.1 
User-Agent: AdExchangeBuyer google-api-dotnet-client/1.9.1.12394 (gzip)

这是使用网络界面(https://developers.google.com/ad-exchange/buyer-rest/v1.3/creatives/list)的请求:

GET https://www.googleapis.com/adexchangebuyer/v1.3/creatives?buyerCreativeId=i7bhb44u&buyerCreativeId=f5bfbul2&key={YOUR_API_KEY}

1 个答案:

答案 0 :(得分:0)

看起来呼叫太长了,你有点超时。所以我建议尝试下列之一:

  1. 如果您有超过x(在您的情况下为10)项目,请将其拆分为多个呼叫。看起来10件物品需要超过20秒,所以你可以分开它,你不会得到某种超时。
  2. 更改默认超时的数字高于默认值(我读到的地方是100,但我没有在官方文档中找到它 - https://msdn.microsoft.com/en-us/library/system.net.http.httpclient.timeout%28v=vs.118%29.aspx)。您可以执行以下操作:

    this.AdexchangebuyerService.HttpClient.Timeout = 
         TimeSpan.FromSeconds(200);