public void Run() { ApiAuthentication auth = null; //auth = new PasswordAuthentication("username", "passsword", "developerToken"); auth = new OAuthAuthentication( "accessToken", "refreshToken", "developerToken", DateTime.UtcNow.Ticks, "clientId"); IList <AccountInfo> accounts = null; using (CustomerMHelper cs = new CustomerMHelper(LogHandler)) { var response = cs.TryGetAccountsInfo(auth, CustomerId, true); if (response != null && response.AccountsInfo != null) { accounts = response.AccountsInfo.ToList(); } } if (accounts == null || accounts.Count == 0) { return; } //you can submit a report request which could most contain 1000 accountIds per time //if you have more than 1000 accounts, then you should submit the report request every 1000 accountIds //for demo, we just pick up the first 1000 accountIds if (accounts.Count > 1000) { accounts = accounts.TakeWhile((p, i) => { return(i < 1000); }).ToList(); } using (ReportingHelper rs = new ReportingHelper(LogHandler)) { //Submit & download var succeed = rs.TrySubmitGenerateReport(auth, BuildRequest(accounts.Select(p => p.Id).ToArray()), CustomerId, null, SaveFilePath); } }