在 Ad Exchange 卖家 REST API 中运行大型报告



我有一个要求,必须在 Ad Exchange 卖家 REST API 中运行大型报告。引用网址 https://developers.google.com/ad-exchange/seller-rest/reporting/large_reports。我按照提到的步骤仍然只得到 100,000 行,而且响应不是 CSV 文件。

        AdExchangeSellerService asv;
        using (var stream = new FileStream(@"client_secrets.json", FileMode.Open, FileAccess.Read))
        {
            GoogleWebAuthorizationBroker.Folder = "Tasks.Auth.Store";
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, new[] { AdExchangeSellerService.Scope.AdexchangeSeller },
                "abc@gmail.com", CancellationToken.None).Result;
           asv = new AdExchangeSellerService(new AdExchangeSellerService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Test108",
            });

        }
        var startDate = System.DateTime.Now.AddDays(-k).ToString("yyyy-MM-dd");
        var endDate = System.DateTime.Now.AddDays(-k).ToString("yyyy-MM-dd"); 

       var reportRequest = asv.Accounts.Reports.Generate("357435743543565337", startDate, endDate);
        reportRequest.Metric = new List<string> { "AD_REQUESTS", "CLICKS", "MATCHED_AD_REQUESTS_RPM", "EARNINGS", "MATCHED_AD_REQUESTS" };
        reportRequest.Dimension = new List<string> { "DATE", "ADVERTISER_NAME", "AD_TAG_NAME", "COUNTRY_NAME", "PRODUCT_NAME", "TRANSACTION_TYPE_NAME", "BRANDING_TYPE_NAME","AD_UNIT_SIZE_NAME" };

        Google.Apis.Discovery.Parameter param = new Google.Apis.Discovery.Parameter();
        param.Name = "alt";
        param.DefaultValue = "media";
        param.ParameterType = "query";
        param.Pattern = null;
        reportRequest.RequestParameters.Remove("alt");

        reportRequest.RequestParameters.Add("alt", param);
        Google.Apis.AdExchangeSeller.v2_0.Data.Report reportResponse = reportRequest.Execute();

我所期望的是响应应该是某种CSV文件的格式,但我得到的是某种表格格式的数据。我在这里错过了什么?

reportRequest.Alt = AdExchangeSellerBaseServiceRequest<Google.Apis.AdExchangeSeller.v2_0.Data.Report>.AltEnum.Csv;
        Stream str = File.Create(csvFilePath);
        reportRequest.Download(str);
        str.Close();
        FileInfo fi = new FileInfo(csvFilePath);
        Decompress(fi);
        DataTable reportResponse = ImportExcel(csvFilePath.Replace("zip","csv"),startDate,endDate);

我终于完成了:)