0

**Is there a way to get the data from a report request without downloading a file? ** I am currently using the Bing API to get a Campaign Performance Report through the CampaignPerformancReportRequest class. I want to take the data and use it to show some metrics. The load of my app is very high. The users count are millions so loading all data for each user then reading from file will be very slow. Can anyone help? Here is my code I am currently using, But I do hope to find some way to get rid of reading/downloading files.

        var reportRequest = new CampaignPerformanceReportRequest {
            ReportName = "CampaignPerformanceReport",
            ExcludeColumnHeaders = false,
            ExcludeReportFooter = true,
            ExcludeReportHeader = false,
            Format = ReportFormat.Csv,
            Aggregation = ReportAggregation.Daily,
            ReturnOnlyCompleteData = false,
            Columns = new[]
            {
                CampaignPerformanceReportColumn.CampaignId,
                CampaignPerformanceReportColumn.CampaignName,
                CampaignPerformanceReportColumn.CampaignType, 
                CampaignPerformanceReportColumn.CampaignStatus,
                CampaignPerformanceReportColumn.Impressions,
                CampaignPerformanceReportColumn.TimePeriod
                  
            },
            Scope = new AccountThroughCampaignReportScope {
                AccountIds = new List<long>() { 11, 22},
            },
            Filter = new CampaignPerformanceReportFilter() {
                Status = CampaignStatusReportFilter.Active | CampaignStatusReportFilter.Paused | CampaignStatusReportFilter.BudgetPaused | CampaignStatusReportFilter.Suspended
            },
            Time = new ReportTime {
                CustomDateRangeStart = new Microsoft.BingAds.V13.Reporting.Date() { Day = 10, Month = 7, Year = 2020 },
                CustomDateRangeEnd = new Microsoft.BingAds.V13.Reporting.Date() { Day = 9, Month = 7, Year = 2023 },          
                ReportTimeZone = ReportTimeZone.EasternTimeUSCanada
            }
        };

        var reportingDownloadParameters = new ReportingDownloadParameters {
            ReportRequest = reportRequest,
            ResultFileName = "n12t",
            OverwriteResultFile = true,
        };

        Report reportContainer = (await reportingServiceManager.DownloadReportAsync(
                  parameters: reportingDownloadParameters,
                  cancellationToken: CancellationToken.None));

        long recordCount = reportContainer.ReportRecordCount;
        IEnumerable<IReportRecord> reportRecordIterable = reportContainer.GetReportRecords();
        int totalImpressions = 0;
        foreach (IReportRecord record in reportContainer.GetReportRecords()) {
            totalImpressions += record.GetIntegerValue("Impressions");
        }

        reportContainer.Dispose();
        reportingServiceManager.CleanupTempFiles();

I am trying to find a good way to deal with Bing Ads api reporting in case of large number of users

0 Answers0