Get a list of all the accounts that is accessible by the MCC account which my user has access to.

521 views
Skip to first unread message

dar...@companionlabs.com

unread,
Jan 23, 2019, 5:39:58 PM1/23/19
to AdWords API and Google Ads API Forum
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. 


googleadsapi...@google.com

unread,
Jan 24, 2019, 3:59:02 AM1/24/19
to AdWords API and Google Ads API Forum
Hi,

Could you clarify if you would want to get the hierarchy of the accounts under your manager account? If so, then you may use  customer_client resource. Below query should work to get the said hierarchy:

.setQuery("SELECT customer.id, customer.descriptive_name, customer_client.resource_name, customer_client.client_customer, customer_client.level, customer_client.hidden FROM customer_client")

Let me know if you encounter problems.

Best regards,
Jaki
AdWords 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

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/24/19 02:52:41 dar...@companionlabs.com wrote:
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.

dar...@companionlabs.com

unread,
Jan 24, 2019, 1:59:49 PM1/24/19
to AdWords API and Google Ads API Forum
Hi Jaki,
I have marked your response as complete as it answers my original questions, but I have a follow up questions. Is there a way to also pull the customer name and/or descriptive name of the customer_client.client_customer from the Search Service. I used the CustomerService to getCustomer to pull the customer name/descriptive_name etc but due to the sear number of client_customer I am getting ResourceExhaustedException. It would be nice to pull these other details from the Search Service if possible, or any other better way?

googleadsapi...@google.com

unread,
Jan 25, 2019, 2:38:50 AM1/25/19
to AdWords API and Google Ads API Forum
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 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

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

Darshan Pradhan

unread,
Jan 31, 2019, 10:13:15 AM1/31/19
to AdWords API and Google Ads API Forum
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?

googleadsapi...@google.com

unread,
Feb 1, 2019, 5:51:09 AM2/1/19
to AdWords API and Google Ads API Forum
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

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

Message has been deleted

Darshan Pradhan

unread,
Feb 4, 2019, 9:37:28 AM2/4/19
to AdWords API and Google Ads API Forum
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 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;
}
}

googleadsapi...@google.com

unread,
Feb 5, 2019, 2:41:22 AM2/5/19
to AdWords API and Google Ads API Forum
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 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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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

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

googleadsapi...@google.com

unread,
Feb 5, 2019, 5:13:53 AM2/5/19
to AdWords API and Google Ads API Forum
Hi Darshan,

Please see my updated response below.

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 is a limitation specified in the Google Ads API Beta related to requests frequency. The workaround solution you implemented by adding a delay is correct. Controlling the frequency of your requests is the recommended solution for this limitation. You could refer to our best practices guide for references.

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

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

Darshan Pradhan

unread,
Feb 22, 2019, 10:41:02 AM2/22/19
to AdWords API and Google Ads API Forum
Update incase someone has similar case to solve as I did, which was I needed to pull all the customer details including name (which is not available in the customer_client call) under a mcc account. The only way to pull htis fro beta (as of today) is to query customer_client but it does not have name and you have to loop through each record to pull customer detail which inevitably failed if you have fare amount of accounts under mcc. I had to go back to adwords api and make the managedCustomerService.get(selectorBuilder.build()) to fetch all the customers with name. 

cv

unread,
May 27, 2019, 1:57:36 AM5/27/19
to AdWords API and Google Ads API Forum
Hello Dannison/Darshan,

This RESOURCE_EXHAUSTED limitation is very annoying, we can have 30 request/minute which I thought is less when we collect data through search query or making list out all the accounts.

Like I am just making search query request with 50 accounts and going through to get Descriptive Name and other Information like timezone and currency for the accounts that I got through customer_clients.

I am getting RESOURCE_EXHAUSTED in about 20 - 25 accounts when do the getCustomer information request.

How much time required to stop API call, which was given through Adwords API (retry after X seconds)


Thanks,

Google Ads API Forum Advisor Prod

unread,
May 27, 2019, 5:45:30 AM5/27/19
to adwor...@googlegroups.com
Hi,

My apologies for the complications you may be encountering. The RESOURCE_EXHAUSTED error does not provide a retryAfterSeconds value. The reason you are encountering this is when you are hitting the Daily API operation limits or the Get requests count. You may consider applying for Standard Access developer token or implement the best practices to decrease the chance of encountering this error.

Regards,
Dannison
Google Ads API Team

ref:_00D1U1174p._5001UAqiuI:ref

cv

unread,
May 27, 2019, 8:42:14 AM5/27/19
to AdWords API and Google Ads API Forum
Hi Dannison,

I am doing operations with  Standard Access developer token.
I am doing best practise as well ( I mentioned that I am doing a pagination size of 20 records with delay of 5 seconds on each page request), but the operation demand requires those limit, which is uncommon.

We can get all customers Info with 1 API call in Adwords API but here we required as many api calls as no of accounts.

error which I was getting
Status code: 8
"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'.
Failure: {} 



Thanks,

Google Ads API Forum Advisor Prod

unread,
May 27, 2019, 11:14:43 PM5/27/19
to adwor...@googlegroups.com
Hi,

Sorry for the inconvenience this may have caused. The Standard Access level has a limit of 1000 get requests per day as per this guide. The limit will reset a little over 24 hours before you can start making GET request again in the API. However, if you think that you are encountering this error more frequently than often, feel free to open your request and we will be happy to investigate it further for you.

John

unread,
Jun 12, 2019, 5:24:25 PM6/12/19
to AdWords API and Google Ads API Forum
Hi cv,

You should use search requests instead of get requests to retrieve information about all individual customers.
Search requests are not limited to 1000 requests per day and only count for the operation limit, which is unlimited for standard access.

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.

In pseudo-code:

accessibleCustomers = Customer.ListAccessibleCustomers()
for(customer in accessibleCustomers) {
  id = extractIdFromResourceName(customer)
  customer_clients = GoogleAdsService.Search(id, 'SELECT customer_client.client_customer FROM customer_client')
  for(customer_client in customer_clients) {
    client_id = extractIdFromResourceName(customer_client.client_customer)
    GoogleAdsService.Search(client_id, 'SELECT customer.id, customer.descriptive_name FROM customer')
  }
}

Jean-Fabrice Rabaute

unread,
Jun 12, 2019, 7:11:29 PM6/12/19
to AdWords API and Google Ads API Forum
A lot of people are asking about the same thing, because the "search" api does not work. The select does not return the information needed by clients usually.
Data is missing and a subsequent call for each customer is needed to get more details.
So this "solution" does not work in the real world.

You can see here the list of questions related to this problem: https://groups.google.com/forum/#!searchin/adwords-api/ListAccessibleCustomers|sort:date


Hopefully the Ads team is solving this problem soon.

Jean-Fabrice Rabaute

unread,
Jun 12, 2019, 7:14:40 PM6/12/19
to AdWords API and Google Ads API Forum
Sorry, to make it a bit more explicit, this still generates N queries instead of one. In the previous API, one query was returning everything.
Here, one query per customer is needed, and when there are 1000 accounts under an MCC account, it takes several minutes to get back all the information, and it was taking several seconds only using the old API.

Google Ads API Forum Advisor Prod

unread,
Jun 13, 2019, 4:16:17 AM6/13/19
to adwor...@googlegroups.com
Hi,

My apologies for the current limitation of this feature. The engineering team is currently working on a better solution on how to retrieve customer details efficiently. For the mean time, you may keep an eye on our blog for news and updates regarding this.

John

unread,
Jun 13, 2019, 8:36:42 PM6/13/19
to AdWords API and Google Ads API Forum
I agree.
At least a customer_client_descriptive_name field should be available in the customer_client resource to make a flat list of all available accounts with customer_id and name.

Google Ads API Forum Advisor Prod

unread,
Jun 13, 2019, 11:25:21 PM6/13/19
to adwor...@googlegroups.com
Hi John,

Thank you for the suggestion. I will file a feature request on this. However, I cannot provide a comment on when this will be supported. For the mean time, you may keep an eye on our blog for news and updates regarding the Google Ads API.

Regards,
Dannison
Google Ads API TEam

ref:_00D1U1174p._5001UAqiuI:ref

cv

unread,
Jun 18, 2019, 8:45:53 AM6/18/19
to AdWords API and Google Ads API Forum
Hello John,

Yes I know I can get the data that way but earlier API was giving issue to accounts that is deleted/draft accounts.

How I can remove those accounts?

Thanks,

Google Ads API Forum Advisor Prod

unread,
Jun 19, 2019, 1:12:22 AM6/19/19
to adwor...@googlegroups.com
Hi,

Could you further elaborate the issue you are pertaining to with deleted/draft accounts? 

cv

unread,
Jun 19, 2019, 1:26:25 AM6/19/19
to AdWords API and Google Ads API Forum

Google Ads API Forum Advisor Prod

unread,
Jun 19, 2019, 6:28:14 AM6/19/19
to adwor...@googlegroups.com
Hi,

Since this is a new issue, I would appreciate it if you could open your concern on a new forum thread instead for better tracking. This is so other users will also not get confused on the issues on this post. Rest assured that our team will provide support for your concern.
Reply all
Reply to author
Forward
0 new messages