Hi Darshan,

Upon checking your code, I can confirm that your code appears to be
logically correct. Since you are encountering the RESOURCE_EXHAUSTED error,
I am afraid that this could be a limitation in the Google Ads API Beta. The
workaround solution you implemented by adding a delay is correct. However,
if you still encounter this error continuously, you would want to consider
continuing your API requests in the next day to refresh your account limit.

You could refer to our best practices guide
<https://developers.google.com/google-ads/api/docs/best-practices> for more
information.

Regards,
Dannison
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

On 02/04/19 22:37:27 dars...@companionlabs.com wrote:

Hi Dannison,

Thanks for reaching out to help. I have provided some code snippet below
that I am using which grabs the list of Customer Accounts the user has
access to and then using those customer Accounts it fetches the customer's
clients.

As seen below the list of accessible customer is first pulled and then
customer_client calls are being made. I have commented the code that tries
to pull the customer.name in a loop because the call to customerClients
<https://developers.google.com/google-ads/api/docs/fields/customer_client> does
not return name of the client which i need to present to the user in the UI.

     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;
    }
}



On Friday, February 1, 2019 at 5:51:09 AM UTC-5, googleadsapi-forumadvisor
wrote:

Hi Darshan,

I am a colleague of Jaki, allow me to provide support for your concern. GET
operation is supported in the AdWords API's BatchJobService but it only
returns the status of the existing batchJobs. Also, batch jobs are not yet
supported in the Google Ads API Beta. Could you provide the code segment
where you are trying to retrieve your customers? This is so I can have a
better look in your implementation and provide insights. Generally, for
RESOURCE_EXHAUSTED, we recommend to control your requests by putting delays
or combining more operations in fewer requests.

Regards,
Dannison
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.

Take Survey
<https://support.google.com/google-ads/contact/survey_transactional?caseid=7-0235000025009&hl=en&ctx=1>

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
On 01/31/19 23:13:15 dar...@companionlabs.com wrote:

Thanks for the advise Jaki, I am not having luck with adding delays between
the calls to fetch all the customer's info  (name) under our manager
account which has about 91 accounts and growing, so the calls are failing
in some way also when trying to pull customer name for all linked accounts
and putting in delay the customer has to wait a lot of time to see the
accounts. I can't find anyway to batch the search queries or even batch
multiple customer service.GetCustomer call. I think the batch are mostly
mutate operation.  Thoughts?

On Friday, January 25, 2019 at 2:38:50 AM UTC-5, googleadsapi-forumadvisor
wrote:

Hi Darshan,

Unfortunately, it is not currently possible to get the descriptive name of
client_customer via the customer_client resource.

Also, The RESOURCE_EXHAUSTED
<https://developers.google.com/google-ads/api/docs/common-errors#resource_exhausted>
error you are encountering could be caused by an exceeded system frequency
limit due to sending too many requests in a short period of time. I would
recommend that you set up short delays between requests or combine more
operations in fewer requests to avoid such error.

Best regards,
Jaki
Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.

Take Survey
<https://support.google.com/google-ads/contact/survey_transactional?caseid=7-0235000025009&hl=en&ctx=1>

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
On 01/25/19 02:59:49 dar...@companionlabs.com wrote:

Hi Jaki,
I have ma

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 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
--- 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+unsubscr...@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/4g2ogungb00000008o5j4k000pafnuy6smj0chj6ko30c1g68qj0c1p%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  • Get a l... darshan
    • RE... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
      • ... darshan
        • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
          • ... Darshan Pradhan
            • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
              • ... Darshan Pradhan
              • ... Darshan Pradhan
                • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
                • ... googleadsapi-forumadvisor via AdWords API and Google Ads API Forum
                • ... Darshan Pradhan

Reply via email to