We are executing the following method to extract all accounts (Customer ids) associated to our topLevelAcct. We take the results of this method and make individual calls on each account to extract Google Ads Reports (Criteria, KeywordPerformance and Ad Performance) on these accounts. The subsequent report requests on many of the accounts result in 'ApiException{applicationExceptionType=ApiException, errors=[AuthorizationError{apiErrorType=AuthorizationError, errorString=AuthorizationError.CUSTOMER_NOT_ACTIVE, fieldPath=, reason=CUSTOMER_NOT_ACTIVE, trigger=<null>}]}'
Up to and through Saturday evening the ManagedCustomerService was not returning inactive Customers. Sunday morning just after midnight eastern standard time, inactive accounts have been returned.
What has changed?
Is there a way to modify the ManagedCustomerService request to not return inactive accounts(Customers)
Thank you for your assistance.
public Set<Account> getSubAccounts(final String topLevelAcct) {
final Set<Account> toReturn = new HashSet<>();
final Set<Account> parentAccounts = new HashSet<>();
final Credential creds = getOAuth2Credentials(topLevelAcct);
if (null == creds) {
return toReturn;
}
final AdWordsSession session = createAdWordsSession(creds, topLevelAcct, topLevelAcct);
final AdWordsServices services = new AdWordsServices();
ManagedCustomerServiceInterface mcs = services.get(session, ManagedCustomerServiceInterface.class);
int offset = 0;
SelectorBuilder builder = new SelectorBuilder()
.fields(ManagedCustomerField.CustomerId, ManagedCustomerField.Name)
.offset(offset)
.limit(10000);
ManagedCustomerPage page = null;
do {
try {
page = mcs.get(builder.build());
offset += 100;
} catch (RemoteException e) {
System.err.println("RemoteException getting account info:");
e.printStackTrace();
}
if (null != page) {
ManagedCustomer[] customers = page.getEntries();
for (ManagedCustomer customer : customers) {
Account acct = new AdWordsAccount(customer.getCustomerId());
toReturn.add(acct);
if (customer.getCanManageClients() != null && customer.getCanManageClients()) {
parentAccounts.add(acct);
}
}
builder.offset(offset);
page = null;
} else {
System.err.println("Page was null!");
break;
}
} while(null != page && toReturn.size() < page.getTotalNumEntries());
if (!parentAccounts.isEmpty()) {
for (Account pAcct : parentAccounts) {
pAcct.addSubAccounts(getSubAccounts(pAcct.getId()));
}
}
return toReturn;