Migrate getCustomers method from Ad Words to Google Ads
We are in process of migrating code from Ad Words to Google Ads. First step from this is to get all customers which are assigned to for logged in user. For this Ad Words has an API called "CustomerServiceInterface.getCustomers" method which returns all customers at once.
But in Google Ads, there doesn't seem to be similar method. All we could find was get-account-hierarchy
Looking at the code, it is getting all child accounts by recursion method.
This has a major performance bottleneck as it has to iterate over all accessible customers first and then recursively over all manager and their children.
Question for the experts here - is there any efficient way I can get all customers at once? At least can we get all managers accessible to logged in user?
We did find a relevant article - https://groups.google.com/g/adwords-api/c/UHWxe7ag7zI. But that seems to talk about API quota rather than performance.
It depends. Are you using a service account or authorization credentials for the user?
This matters because you can run a simple query against the regular service on the customer_client resource to get the logged in customer accounts.
SELECT customer_client.client_customer, customer_client.level, customer_client.manager, customer_client.descriptive_name, customer_client.currency_code, customer_client.time_zone, customer_client.id FROM customer_client WHERE customer_client.level <= 1I am using logged in users' credentials. If I run this query, it does not give all levels below current logged in user.
Then just remove the condition in the where clause.
That does not work, I have tried it. It still gives immediate next level accounts only. Code given in developers.google.com/google-ads/api/docs/account-management/… has a line "managerAccountsToSearch.add(customerClient.getId());" which does the recursion. We need this to get child accounts at all Levels.
Can you update your question with the code and query you're using?
Question does contain the code we are using. developers.google.com/google-ads/api/docs/account-management/… and the code contains the query.