.setQuery("SELECT customer.id, customer.descriptive_name, customer_client.resource_name, customer_client.client_customer, customer_client.level, customer_client.hidden FROM customer_client")
Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
Currently the closest I got to listing the accounts that my user has access to is CustomerService.ListAccessibleCustomers, which only lists the customers accounts that are directly accessible to which are the list of my dummy accounts and a MCC account. I would like to list the account accessible by the MCC account as well since my user is tied to the MCC account. I cannot find any thing in the google docs . Does anybody know if this functionality is available or will it be available at some point in new google Ads (beta) api.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/12f82ece-7657-4b46-b4b6-c9c50f545e5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/64612de9-67fe-4a6b-afa7-c8a7a35e4c7f%40googlegroups.com.
Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/6e9fc753-5828-4101-8018-7e3355db7c56%40googlegroups.com.
try {
List<CustomerAccount> customerAccounts = new ArrayList<>();
ListAccessibleCustomersResponse customersResponse = customerServiceClient
.listAccessibleCustomers(ListAccessibleCustomersRequest.newBuilder().build());
for (String resourceName : customersResponse.getResourceNamesList()) {
Customer directAccessibleCustomer = customerServiceClient.getCustomer(resourceName);
List<CustomerAccount> customerClientAccounts = searchService
.getCustomerClients(userId, String.valueOf(directAccessibleCustomer.getId().getValue()));
// Can't make these calls to grab the client_customer's info because RESOURCE_EXHAUSTED error occurs.
// Even if this works successfully, it is a poor user experience because the user has to wait a lot of time
// to retrieve complete list of all the account names
// List<CustomerAccount> completeLinkedAccount = new ArrayList<>();
// for (CustomerAccount customerAccount: customerClientAccounts) {
// Customer linkedCustomer = customerServiceClient.getCustomer(customerAccount.name().get());
// completeLinkedAccount.add(
// ImmutableCustomerAccount.copyOf(customerAccount)
// .withName(linkedCustomer.getResourceName())
// .withDescriptiveName(linkedCustomer.getDescriptiveName().getValue())
// .withId(String.valueOf(linkedCustomer.getId().getValue()))
// .withDateTimeZone(linkedCustomer.getTimeZone().getValue())
// .withCurrencyCode(linkedCustomer.getCurrencyCode().getValue()));
// //include type() when manager field is available in java client
// randomDelay();
// }
CustomerAccount ca = ImmutableCustomerAccount
.builder()
.id(String.valueOf(directAccessibleCustomer.getId().getValue()))
.name(directAccessibleCustomer.getResourceName())
.descriptiveName(directAccessibleCustomer.getDescriptiveName().getValue())
.dateTimeZone(directAccessibleCustomer.getTimeZone().getValue())
.currencyCode(directAccessibleCustomer.getCurrencyCode().getValue())
.linkedAccounts(customerClientAccounts)
// .linkedAccounts(completeLinkedAccount)
.build();
customerAccounts.add(ca);
}
return customerAccounts;
} catch (ApiException e) {
logger.info("error occurred", e);
// // Apparently This does not work since I do not have get back getRetryAfterSeconds.
// for (ApiError error : e.getErrors()) {
// if (error instanceof RateExceededError) {
// RateExceededError rateExceeded = (RateExceededError) error;
// Thread.sleep(rateExceeded.getRetryAfterSeconds() * 1000);
// }
// }
throw e;
} catch (Exception ex) {
logger.error("Error occurred", ex);
throw ex;
}
@Override
public List<CustomerAccount> getCustomerClients(String userId, String customerId) {
GoogleAdsServiceClient googleAdsServiceClient = getGoogleAdsServiceClient(userId, customerId);
String searchQuery = "SELECT "
+ "customer.id, "
+ "customer.descriptive_name, "
+ "customer_client.resource_name, "
+ "customer_client.client_customer, "
+ "customer_client.level, "
+ "customer_client.hidden FROM customer_client";
SearchGoogleAdsRequest request =
SearchGoogleAdsRequest.newBuilder()
.setCustomerId(customerId)
.setPageSize(PAGE_SIZE)
.setQuery(searchQuery)
.build();
try {
GoogleAdsServiceClient.SearchPagedResponse searchPagedResponse = googleAdsServiceClient.search(request);
List<CustomerAccount> returnList = new ArrayList<>();
int counter = 0;
for (GoogleAdsRow gar : searchPagedResponse.iterateAll()) {
String id = extractIdFromResourceName(gar.getCustomerClient().getClientCustomer().getValue());
if (!id.equals(customerId)) {
returnList.add(ImmutableCustomerAccount
.builder()
.id(id)
.name(gar.getCustomerClient().getClientCustomer().getValue())
.linkedLevelFromParent(Long.toString(gar.getCustomerClient().getLevel().getValue()))
.linkedParentId(customerId)
.hidden(String.valueOf(gar.getCustomerClient().getHidden().getValue()))
.type(accountType)
.build());
counter++;
}
}
return returnList;
} catch (GoogleAdsException ex) {
logger.error(String.format("Error occurred: [ %s ]: [ %s]",
ex.getGoogleAdsFailure().getErrors(0).getErrorCode(),
ex.getGoogleAdsFailure().getErrors(0).getMessage()));
throw ex;
} catch (Exception ex) {
logger.error("error", ex);
throw ex;
}
}
Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
"status": "RESOURCE_EXHAUSTED",Details: Quota exceeded for quota metric 'googleads.googleapis.com/get_requests' and limit 'GetsPerMinutePerProject' of service 'googleads.googleapis.com' for consumer 'project_number:64XXXXXX109'.
Search requests are not considered to be the same as get requests, even though both are used to retrieve data. Therefore, search requests are only subject to daily operation limits.