googleads-python-lib icon indicating copy to clipboard operation
googleads-python-lib copied to clipboard

create_dfa_client_without_yaml.py example doesn't work

Open elcct opened this issue 12 years ago • 4 comments

First of all:

dfa_client.GetService('CampaignService')

isn't right, because there is no 'CampaignService':

googleads.errors.GoogleAdsValueError: Unrecognized service for the DFA API. Service given: CampaignService Supported services: ('ad', 'advertiser', 'advertisergroup', 'campaign', 'changelog', 'contentcategory', 'c
reative', 'creativefield', 'creativegroup', 'login', 'network', 'placement', 'site', 'size', 'spotlight', 'strategy', 'subnetwork', 'user', 'userrole', 'report')

Calling:

  results = dfa_client.GetService('campaign').getCampaignsByCriteria({})

Results in:

ERROR:suds.client:<suds.sax.document.Document instance at 0x00000000032899C8>
Traceback (most recent call last):
  File "create_dfa_client_without_yaml.py", line 60, in <module>
    APPLICATION_NAME)
  File "create_dfa_client_without_yaml.py", line 51, in main
    results = dfa_client.GetService('campaign').getCampaignsByCriteria({})
  File "C:\Python27\lib\site-packages\googleads\common.py", line 229, in MakeSoapRequest
    for arg in args])
  File "C:\Python27\lib\site-packages\suds\client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python27\lib\site-packages\suds\client.py", line 581, in invoke
    result = self.send(soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 619, in send
    description=tostr(e), original_soapenv=original_soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 670, in process_reply
    raise WebFault(fault, replyroot)
suds.WebFault: Server raised fault: '20001 - You must specify request parameter for method .'

It seems like this library doesn't work at all - whatever call I make I get:

suds.WebFault: Server raised fault: '20001 - You must specify request parameter for method .'

I tried it with Python 2.7.

elcct avatar Apr 01 '14 20:04 elcct

Just to update. I managed to get it working.

As in the example:

.getCampaignsByCriteria({})

Call above will not work with empty criteria. I didn't have any campaigns to search for so first I tried different method:

dfa_client.GetService('size').getSizes({})

It gave me the same error as in my first post, but same kind of call works with legacy lib.

When changed to:

dfa_client.GetService('size').getSizes({'ids': [0]})

It worked, but then I got error:

suds.WebFault: Server raised fault: '1071 - Failed to authenticate. User profile name [email protected] not found.

After I put USER_PROFILE_NAME = 'xxx' omitting domain name it worked.

I hope that helps...

I ended up using legacy lib for now.

elcct avatar Apr 02 '14 01:04 elcct

Hey there,

Thanks for reporting this. There's a few problems here that I'm fixing right now.

  • I put "CampaignService" instead of "campaign" for the service name. Whoops. Must have had AdWords on the brain.
  • Suds doesn't pack empty objects into XML... at all. I've tweaked our serialization code to force suds to do this, so this will work now.
  • Your login error I'm not too sure about. Your user profile name has to be your DFA user profile, not your Google Account. That may have been your issue. I did also notice though that every other DFA example runs against the test environment except the one you tried, which runs against production. I've changed this example to also use the test environment.

I'll make a release to fix this in about an hour.

jdilallo avatar Apr 02 '14 13:04 jdilallo

The release fixing these issues it out.

jdilallo avatar Apr 02 '14 14:04 jdilallo

Login issue was a mix-up - I have DFA username same as Google account username I used to authenticate with OAuth.

I hope this will change in future - use of two accounts to operate the API seems really weird.

Thank you.

elcct avatar Apr 03 '14 01:04 elcct