Zero campaigns returned from call to CampaignService.get using Python AdWords SDK

46 views
Skip to first unread message

Scott Burkhalter

unread,
Jan 16, 2019, 6:13:11 AM1/16/19
to AdWords API and Google Ads API Forum
I'm following the examples included in the googleads-python-lib to learn how to call Get on the CampaignsService - https://github.com/googleads/googleads-python-lib/blob/master/examples/adwords/v201809/basic_operations/get_campaigns.py

I'm receiving an empty response from the API - numEntries equals 0

Can someone help me understand why?

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
 
<soap-env:Header>
   
<ns0:RequestHeader xmlns:ns0="https://adwords.google.com/api/adwords/cm/v201809">
     
<ns0:developerToken>REDACTED</ns0:developerToken>
     
<ns0:userAgent>unknown (AwApi-Python, googleads/15.0.2, Python/2.7.15, zeep)</ns0:userAgent>
     
<ns0:validateOnly>false</ns0:validateOnly>
     
<ns0:partialFailure>false</ns0:partialFailure>
   
</ns0:RequestHeader>
 
</soap-env:Header>
 
<soap-env:Body>
   
<ns0:get xmlns:ns0="https://adwords.google.com/api/adwords/cm/v201809">
     
<ns0:serviceSelector>
       
<ns0:fields>Id</ns0:fields>
       
<ns0:fields>Name</ns0:fields>
       
<ns0:fields>Status</ns0:fields>
       
<ns0:paging>
         
<ns0:startIndex>0</ns0:startIndex>
         
<ns0:numberResults>100</ns0:numberResults>
       
</ns0:paging>
     
</ns0:serviceSelector>
   
</ns0:get>
 
</soap-env:Body>
</soap-env:Envelope>


[2019-01-15 17:21:34,002 - googleads.soap - DEBUG] Incoming response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 
<soap:Header>
   
<ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809">
     
<requestId>00057f89193535f00a62b504be069a16</requestId>
     
<serviceName>CampaignService</serviceName>
     
<methodName>get</methodName>
     
<operations>1</operations>
     
<responseTime>259</responseTime>
   
</ResponseHeader>
 
</soap:Header>
 
<soap:Body>
   
<getResponse xmlns="https://adwords.google.com/api/adwords/cm/v201809">
     
<rval>
       
<totalNumEntries>0</totalNumEntries>
       
<Page.Type>CampaignPage</Page.Type>
     
</rval>
   
</getResponse>
 
</soap:Body>
</soap:Envelope>



googleadsapi...@google.com

unread,
Jan 16, 2019, 11:09:32 AM1/16/19
to AdWords API and Google Ads API Forum
Hello Scott,

Could you please share the client customer id so that I can troubleshoot the issue? Please note that to get the campaign data, you will need to run the CampaignService.get API call against the non manager Google Ads account. You can use 'Reply privately to author' option while responding.

Thanks,
Milind, 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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Scott Burkhalter

unread,
Jan 16, 2019, 3:37:37 PM1/16/19
to AdWords API and Google Ads API Forum
That was the problem :) I had not specified the client_customer_id in the googleads.yaml file.

I need to iterate through a number of accounts for the task I've been assigned. Is there a python example of how to change the campaign_service.client_customer_id on the fly?

Would one create a new client for each account using the LoadFromString() method?

Or can I set the client_service.client_customer_id property on the fly prior to making my get() calls?

For pseudo-code example:


for ccid in list_of_customer_ids:
 
# get the adwords client, would love to pass different client_customer_id to this but not sure how to do so
 client
= adwords.AdWordsClient.LoadFromString(ccid)

 
# or, instead, can I just set the property like this
 client
.client_customer_id = ccid

 
# obtain the campaign service proxy
 campaign_service
= client.GetService('CampaignService', version='v201809')

 
#execute the query
 query
= (adwords.ServiceQueryBuilder()
 
.Select('Id', 'Name', 'Status', 'Labels')
 
.OrderBy('Name')
 
.Limit(0, PAGE_SIZE)
 
.Build())

 
# do stuff with the campaigns....

 
for page in query.Pager(campaign_service):
   
... do stuff with campaign info...




Thanks for any guidance

googleadsapi...@google.com

unread,
Jan 17, 2019, 2:11:24 PM1/17/19
to AdWords API and Google Ads API Forum
Hello Scott,

You can change the client customer id on fly as mentioned in this guide. Let me know if you have any further questions. 


Thanks,
Milind, 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:
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/42928aed-d056-48be-b8c9-35de779c419d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages