CampaignService.get()

117 views
Skip to first unread message

jona...@garagecoders.net

unread,
May 13, 2015, 12:04:36 PM5/13/15
to adwor...@googlegroups.com
I'm developing an app for ios to show information of adwords' accounts, there is no an api to do this so I used gtm-auth in order to log in, i get the refresh token and de customerId of a test account, after this i send the next request

   <soapenv:Header>
      <v20:RequestHeader>
         <!--Optional:-->
         <v20:clientCustomerId>xxx-xxx-xxxx</v20:clientCustomerId>
         <!--Optional:-->
         <v20:developerToken>xxxxxxxxxxxxxxxxxxxxxx</v20:developerToken>
         <!--Optional:-->
         <v20:userAgent>?</v20:userAgent>
         <!--Optional:-->
         <v20:validateOnly>?</v20:validateOnly>
         <!--Optional:-->
         <v20:partialFailure>?</v20:partialFailure>
      </v20:RequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <v20:get>
         <!--Optional:-->
         <v20:serviceSelector>
            <!--Zero or more repetitions:-->
            <v20:fields>?</v20:fields>
            <!--Zero or more repetitions:-->
            <v20:predicates>
               <!--Optional:-->
               <v20:field>?</v20:field>
               <!--Optional:-->
               <v20:operator>?</v20:operator>
               <!--Zero or more repetitions:-->
               <v20:values>?</v20:values>
            </v20:predicates>
            <!--Optional:-->
            <v20:dateRange>
               <!--Optional:-->
               <v20:min>?</v20:min>
               <!--Optional:-->
               <v20:max>?</v20:max>
            </v20:dateRange>
            <!--Zero or more repetitions:-->
            <v20:ordering>
               <!--Optional:-->
               <v20:field>?</v20:field>
               <!--Optional:-->
               <v20:sortOrder>?</v20:sortOrder>
            </v20:ordering>
            <!--Optional:-->
            <v20:paging>
               <!--Optional:-->
               <v20:startIndex>?</v20:startIndex>
               <!--Optional:-->
               <v20:numberResults>?</v20:numberResults>
            </v20:paging>
         </v20:serviceSelector>
      </v20:get>
   </soapenv:Body>
</soapenv:Envelope>

and the server response with : 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201502">
         <requestId>000515f8227ce7480ab695e8a1006913</requestId>
         <serviceName>CampaignService</serviceName>
         <methodName>get</methodName>
         <operations>0</operations>
         <responseTime>146</responseTime>
      </ResponseHeader>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>[AuthenticationError.NOT_ADS_USER @ ; trigger:'&lt;null>']</faultstring>
         <detail>
            <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201502">
               <message>[AuthenticationError.NOT_ADS_USER @ ; trigger:'&lt;null>']</message>
               <ApplicationException.Type>ApiException</ApplicationException.Type>
               <errors xsi:type="AuthenticationError" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <fieldPath/>
                  <trigger>&lt;null></trigger>
                  <errorString>AuthenticationError.NOT_ADS_USER</errorString>
                  <ApiError.Type>AuthenticationError</ApiError.Type>
                  <reason>NOT_ADS_USER</reason>
               </errors>
            </ApiExceptionFault>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

my developer token is pending but i read that it will work if a used a test account, also, when i get the information of the user the customerId is a different number, not with the format i put before, i have tried with both customerId but i still get this error, i need to know if the access_token it's necessary, the documentation said that yes, but i don`t have a field to include it.

Anthony Madrigal

unread,
May 13, 2015, 3:09:27 PM5/13/15
to adwor...@googlegroups.com, jona...@garagecoders.net
Hey Jonathan,

The error you are getting indicates that the user whose OAuth credentials you are using does not have an AdWords account. Please generate another refresh/ access token, this time making sure you are signed in as a user with access to your test account.

Also, take a look at the SOAP Primer guide since it explains which HTTP header you will need to use when you pass the access token.

Cheers,
Anthony, AdWords API Team

jona...@garagecoders.net

unread,
May 13, 2015, 4:11:41 PM5/13/15
to adwor...@googlegroups.com, jona...@garagecoders.net
Thanks for your answear Anthony Madrigal, as you said i include the header "Authorization" with my access_token and now i get the response, now i have another question, when I logged I get a customerID, this with gtm-auth2 (https://code.google.com/p/gtm-oauth2/wiki/Introduction), but the customerID i get is different from the client id I have in my test account, if I use the customerID(gtm-auth2) I got the same error, I need to get the correct clientID..
there is a way to get the correct clientID ?? 

Anthony Madrigal

unread,
May 14, 2015, 12:08:02 PM5/14/15
to adwor...@googlegroups.com, jona...@garagecoders.net
Hi Jonathan,

You may have confused the client ID from the Developer's Console with the customer ID from AdWords. You will want to use your AdWords CID. You can use the CustomerService.get() without specifying the clientCustomerId SOAP header. For other services, such as CampaignService, you will need to specify a clientCustomerId.

Regards,
Anthony, AdWords API Team

jona...@garagecoders.net

unread,
May 14, 2015, 2:21:21 PM5/14/15
to adwor...@googlegroups.com, jona...@garagecoders.net
I'm trying to get the campaign of the user that log in into the app, when I used the GTM-OAUTH2 i get a clientID, lets say  "104122614809666770682", if a used this value
   <soapenv:Header>
      <v20:RequestHeader>
         <!--Optional:-->
         <v20:clientCustomerId> 104122614809666770682</v20:clientCustomerId>
         <!--Optional:-->
         <v20:developerToken>xxxxxxxxxxxxxxxxxxxxx</v20:developerToken>
         <!--Optional:-->
         <v20:userAgent>PPCMobility</v20:userAgent>
         <!--Optional:-->
         <v20:validateOnly></v20:validateOnly>
         <!--Optional:-->
         <v20:partialFailure></v20:partialFailure>
      </v20:RequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <v20:get>
         <!--Optional:-->
         <v20:serviceSelector>
            <!--Zero or more repetitions:-->
            <v20:fields>Name</v20:fields>
            <!--Zero or more repetitions:-->
            <v20:predicates>
               <!--Optional:-->
               <v20:field>Name</v20:field>
               <!--Optional:-->
               <v20:operator>NOT_EQUALS</v20:operator>
               <!--Zero or more repetitions:-->
               <v20:values></v20:values>
            </v20:predicates>
            <!--Optional:-->
            <v20:dateRange>
               <!--Optional:-->
               <v20:min>20100101</v20:min>
               <!--Optional:-->
               <v20:max>20150310</v20:max>
            </v20:dateRange>
            <!--Zero or more repetitions:-->
            <v20:ordering>
               <!--Optional:-->
               <v20:field>Name</v20:field>
               <!--Optional:-->
               <v20:sortOrder>ASCENDING</v20:sortOrder>
            </v20:ordering>
            <!--Optional:-->
            <v20:paging>
               <!--Optional:-->
               <v20:startIndex>0</v20:startIndex>
               <!--Optional:-->
               <v20:numberResults>1000</v20:numberResults>
            </v20:paging>
         </v20:serviceSelector>
      </v20:get>
   </soapenv:Body>
</soapenv:Envelope>

i got an error, and if a used the number that appear in my test account xxx-xxx-xxxx now i get a correct response, so I don't know how to get the correct user id from google adwords, I try with CustomerService

   <soapenv:Header>
      <v20:RequestHeader>
         <!--Optional:-->
         <v201:clientCustomerId></v201:clientCustomerId>
         <!--Optional:-->
         <v201:developerToken>xxxxxxxxxxxxxxxx</v201:developerToken>
         <!--Optional:-->
         <v201:userAgent></v201:userAgent>
         <!--Optional:-->
         <v201:validateOnly></v201:validateOnly>
         <!--Optional:-->
         <v201:partialFailure></v201:partialFailure>
      </v20:RequestHeader>
   </soapenv:Header>
   <soapenv:Body>
      <v20:get/>
   </soapenv:Body>
</soapenv:Envelope>

without specifing the clientCustomerId and I got

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
         <ns2:requestId>0005160eb16946490ab62784a50068ef</ns2:requestId>
         <ns2:serviceName>CustomerService</ns2:serviceName>
         <ns2:methodName>get</ns2:methodName>
         <ns2:operations>0</ns2:operations>
         <ns2:responseTime>44</ns2:responseTime>
      </ResponseHeader>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>[AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'&lt;null>']</faultstring>
         <detail>
               <ns2:message>[AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'&lt;null>']</ns2:message>
               <ns2:ApplicationException.Type>ApiException</ns2:ApplicationException.Type>
               <ns2:errors xsi:type="ns2:AuthenticationError" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <ns2:fieldPath/>
                  <ns2:trigger>&lt;null></ns2:trigger>
                  <ns2:errorString>AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED</ns2:errorString>
                  <ns2:ApiError.Type>AuthenticationError</ns2:ApiError.Type>
                  <ns2:reason>CLIENT_CUSTOMER_ID_IS_REQUIRED</ns2:reason>
               </ns2:errors>
            </ApiExceptionFault>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

Anthony Madrigal

unread,
May 14, 2015, 5:34:56 PM5/14/15
to adwor...@googlegroups.com, jona...@garagecoders.net
Hello,

When using the CID, you are going to want to use the one from the test AdWords account, not the one from GTM-OAUTH2.

The clientCustomerId header is optional when running CustomerService. If you're not going to specify that value you should exclude that header altogether rather than including it as an empty element, so just remove the line that says:

<!--Optional:-->
<v201:clientCustomerId></v201:clientCustomerId>

This will return a Customer object where the customerId will be the AdWords customer ID of the authenticated user.

Note that for all other services besides CustomerService, the clientCustomerId SOAP header is required.

jona...@garagecoders.net

unread,
May 14, 2015, 5:41:23 PM5/14/15
to adwor...@googlegroups.com, jona...@garagecoders.net
A lot of thanks, now I'm able to get the customerClientId, thank you for your time
Reply all
Reply to author
Forward
0 new messages