Hi Reinhold, Here's a singlethreaded version of the code that works.
public void Run(AdWordsUser user, string directory) { string[] clientCustomerIds = GetChildAccounts(user); ReportDefinition definition = BuildReportDefinition(); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } foreach (String customerId in clientCustomerIds) { (user.Config as AdWordsAppConfig).ClientCustomerId = customerId; ReportUtilities utilities = new ReportUtilities(user); utilities.ReportVersion = "v201209"; utilities.DownloadClientReport(definition, directory + Path.DirectorySeparatorChar + customerId + ".csv"); } } private static ReportDefinition BuildReportDefinition() { ReportDefinition definition = new ReportDefinition(); definition.reportName = "Last 7 days CRITERIA_PERFORMANCE_REPORT"; definition.reportType = ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT; definition.downloadFormat = DownloadFormat.GZIPPED_CSV; definition.dateRangeType = ReportDefinitionDateRangeType.LAST_7_DAYS; // Create selector. Selector selector = new Selector(); selector.fields = new string[] {"CampaignId", "AdGroupId", "Id", "CriteriaType", "Criteria", "CriteriaDestinationUrl", "Clicks", "Impressions", "Cost"}; Predicate predicate = new Predicate(); predicate.field = "Status"; predicate.@operator = PredicateOperator.IN; predicate.values = new string[] {"ACTIVE", "PAUSED"}; selector.predicates = new Predicate[] {predicate}; definition.selector = selector; definition.includeZeroImpressions = true; return definition; } private string[] GetChildAccounts(AdWordsUser user) { List<string> customerIds = new List<string>(); // Get the ManagedCustomerService. ManagedCustomerService managedCustomerService = (ManagedCustomerService) user.GetService( AdWordsService.v201209.ManagedCustomerService); managedCustomerService.RequestHeader.clientCustomerId = null; // Create selector. Selector selector = new Selector(); selector.fields = new String[] {"CustomerId", "CanManageClients"}; ManagedCustomerPage page = managedCustomerService.get(selector); foreach (ManagedCustomer customer in page.entries) { if (!customer.canManageClients) { customerIds.Add(customer.customerId.ToString()); } } return customerIds.ToArray(); } If you are using a multithreaded version, then your code needs to be modified a bit as follows, since user object stores only a reference of config and hence using the same user object across threads can cause threading issues. AdWordsUser clientUser = new AdWordsUser(); (clientUser.Config as AdWordsAppConfig).ClientCustomerId = customerId;ReportUtilities utilities = new ReportUtilities(clientUser); Hope this helps. Let me know if you have more questions. Cheers, Anash P. Oommen, AdWords API Advisor. On Thursday, 13 December 2012 15:41:05 UTC+5:30, Reinhold Maurus wrote: > > Does anyone have a sample code in c# for doing reports for each client in > the MCC account? > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en