Ho to make an query to list all account ids?

166 views
Skip to first unread message

Luiz Eduardo Da Cruz

unread,
Dec 15, 2022, 11:22:22 AM12/15/22
to Google Ads API and AdWords API Forum
Hello, is there a way to get all account ids in my account?

I can get campaign data as follows:


ga_service = client.get_service("GoogleAdsService", version="v7")

query = """
campaign_budget.amount_micros
FROM campaign_budget
ORDER BY campaign_budget.id"""

response = ga_service.search_stream(customer_id=account_id, query=query)

But how can i get the account ids? 

Google Ads API Forum Advisor

unread,
Dec 15, 2022, 12:00:57 PM12/15/22
to adwor...@googlegroups.com
Hi Luiz,

By "get all account ids in my account" do you mean getting all client account IDs under your MCC / manager account? If yes, you can refer to our get account hierarchy guide for the details as to how.

You can then generate a report for each client account returned, and you can refer to this example for the implementation. Let us know if this is what you're looking for.

Lastly, I noticed you specified the version="v7" in your post. You can refer here for the currently supported versions of the API. We then recommend using the latest version, for the latest API features.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


ref:_00D1U1174p._5004Q2h3RTZ:ref

Luiz Eduardo Da Cruz

unread,
Dec 15, 2022, 1:39:11 PM12/15/22
to Google Ads API and AdWords API Forum
I want a query that contains all accounts ids, both mccs and mccs' children, how can I get this query done?

Google Ads API Forum Advisor

unread,
Dec 15, 2022, 2:43:20 PM12/15/22
to adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

With regards to your concern, you can use customer_client report.

Let me know if you have any question.

Thanks,
Google Logo
Nirmita
Google Ads API Team
 


ref:_00D1U1174p._5004Q2h3RTZ:ref

Luiz Eduardo Da Cruz

unread,
Dec 15, 2022, 2:46:47 PM12/15/22
to Google Ads API and AdWords API Forum
 (<_InactiveRpcError of RPC that terminated with:
        status = StatusCode.PERMISSION_DENIED
        details = "The caller does not have permission"
        debug_error_string = "UNKNOWN:Error received from peer ipv--------- {created_time:"2022-12-15T16:44:22.890198-03:00", grpc_status:7, grpc_message:"The caller does not have permission"}"
>, <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.PERMISSION_DENIED
        details = "The caller does not have permission"
        debug_error_string = "UNKNOWN:Error received from peer ipv4-------------- {created_time:"2022-12-15T16:44:22.890198-03:00", grpc_status:7, grpc_message:"The caller does not have permission"}"
>, errors {
  error_code {
    authorization_error: CUSTOMER_NOT_ENABLED
  }
  message: "The customer account can\'t be accessed because it is not yet enabled or has been deactivated."
}
request_id: "--------"
, '----..-p----')

Luiz Eduardo Da Cruz

unread,
Dec 15, 2022, 3:37:41 PM12/15/22
to Google Ads API and AdWords API Forum
im receiving this error,  can someone help? 

Google Ads API Forum Advisor

unread,
Dec 15, 2022, 3:48:25 PM12/15/22
to adwor...@googlegroups.com
Hi Luiz,

To resolve the CUSTOMER_NOT_ENABLED error, you will first need to reactivate the account. Afterwards, you can then proceed in making API calls to that account.

As for the "I want a query that contains all accounts ids, both mccs and mccs' children, how can I get this query done?" concern, you can refer to the get account hierarchy guide that I sent earlier.

Let us know if this helps.

Luiz Eduardo Da Cruz

unread,
Dec 15, 2022, 6:52:18 PM12/15/22
to Google Ads API and AdWords API Forum
tks!
Reply all
Reply to author
Forward
0 new messages