Denis Olifer
Denis Olifer

Reputation: 751

AdWords API : client list for non MCC account

I want to get a list of AdWords clients assigned to authenticated account (i use OAuth).

First attempt was to use ServicedAccountService and this XML request

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <RequestHeader xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <developerToken xmlns="https://adwords.google.com/api/adwords/mcm/v201109">[[DEV_TOKEN]]</developerToken>
    </RequestHeader>
  </soap:Header>
  <soap:Body>
    <get xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <selector>
        <enablePaging>false</enablePaging>
      </selector>
    </get>
  </soap:Body>
</soap:Envelope>

But it works only for MCC accounts. For regular google account i got empty dataset

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/mcm/v201109">
      <ns2:requestId>0004bc71cee633d00aecb0aa000060ca</ns2:requestId>
      <ns2:serviceName>ServicedAccountService</ns2:serviceName>
      <ns2:methodName>get</ns2:methodName>
      <ns2:operations>0</ns2:operations>
      <ns2:responseTime>230</ns2:responseTime>
      <ns2:units>0</ns2:units>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <getResponse xmlns="https://adwords.google.com/api/adwords/mcm/v201109" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109">
      <rval>
        <accounts>
          <customerId>0</customerId>
          <canManageClients>false</canManageClients>
        </accounts>
      </rval>
    </getResponse>
  </soap:Body>
</soap:Envelope>

I googled a lot, and finally found that i can use other XML (InfoService) for both MCC and non MCC accounts.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <RequestHeader xmlns="https://adwords.google.com/api/adwords/info/v201109">
      <developerToken xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[DEV_TOKEN]]</developerToken>
    </RequestHeader>
  </soap:Header>
  <soap:Body>
    <get xmlns="https://adwords.google.com/api/adwords/info/v201109">
      <selector>
        <dateRange>
          <min xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[START_DATE]]</min>
          <max xmlns="https://adwords.google.com/api/adwords/cm/v201109">[[END_DATE]]</max>
        </dateRange>
        <includeSubAccounts>true</includeSubAccounts>
        <apiUsageType>UNIT_COUNT_FOR_CLIENTS</apiUsageType>
      </selector>
    </get>
  </soap:Body>
</soap:Envelope>

But data returned is incorrect - not all accounts are listed. Or no data returned at all.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
            <ns2:requestId>0004bc7121a910e80a97030d000051e7</ns2:requestId>
            <ns2:serviceName>InfoService</ns2:serviceName>
            <ns2:methodName>get</ns2:methodName>
            <ns2:operations>1</ns2:operations>
            <ns2:responseTime>1206</ns2:responseTime>
            <ns2:units>1</ns2:units>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <getResponse xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201109" xmlns="https://adwords.google.com/api/adwords/info/v201109">
            <rval>
                <cost>0</cost>
            </rval>
        </getResponse>
    </soap:Body>
</soap:Envelope>

Is there any other way to get client list for AdWords account? Thanks a lot.

Upvotes: 0

Views: 1173

Answers (1)

Ewan Heming
Ewan Heming

Reputation: 4648

I've also encountered this problem, and can confirm that it's not the correct behaviour of the ServicedAccountService; it's a "known issue that will be resolved in future": If you link your basic account to an MCC, then you can authenticate with the basic account and use the ServicedAccountService to obtain the account details, but if the account isn't linked then you'll get this problem.

If you just want to obtain the customer id for an account, you can also use the InfoService, which doesn't suffer from the same issue.

Upvotes: 1

Related Questions