Adwords API UserListService在调用mutate

时间:2017-03-27 13:04:55

标签: python-2.7 api google-adwords google-api-python-client

我正在使用Google AdWords API userListService添加新的用户列表,我已经通过了所有必需的输入,并成功创建了adword客户端实例。

但是在调用mutate方法时,它会抛出属性错误 " AttributeError:类HttpTransport没有属性' _HttpTransport__get_request_url'"

请找到StackTrace:

追踪(最近一次呼叫最后一次):

文件" C:\ Program Files(x86)\ JetBrains \ PyCharm Community Edition 5 \ helpers \ pydev \ pydevd.py",第2411行,     globals = debugger.run(setup [' file'],None,None,is_module)

文件" C:\ Program Files(x86)\ JetBrains \ PyCharm Community Edition 5 \ helpers \ pydev \ pydevd.py",第1802行,在运行中     启动(文件,全局,本地)#执行脚本

文件" D:/ Python研究/ SVN代码/正在进行的工作/源代码/ doubleclick-Dmp-Integration / DmpIntegrationApplication / dmpintegration / dmpex / adwords.py",第93行,in     主(adwords_client)

文件" D:/ Python研究/ SVN代码/正在进行的工作/源代码/ doubleclick-Dmp-Integration / DmpIntegrationApplication / dmpintegration / dmpex / adwords.py",第33行,主要     result = user_list_service.mutate(operations)

文件" C:\ Python27 \ lib \ site-packages \ googleads \ common.py",第720行,在MakeSoapRequest中     * [args in args中的__ PackForSuds(arg,self.suds_client.factory)])

文件" C:\ Python27 \ lib \ site-packages \ suds \ client.py",第542行,致电     return client.invoke(args,kwargs)

文件" C:\ Python27 \ lib \ site-packages \ suds \ client.py",第602行,在调用中     result = self.send(soapenv)

文件" C:\ Python27 \ lib \ site-packages \ suds \ client.py",第637行,发送     reply = transport.send(request)

文件" C:\ Python27 \ lib \ site-packages \ googleads \ util.py",第92行,在PatchedHttpTransportSend中     url = http_transport._HttpTransport__get_request_url(request)

AttributeError:类HttpTransport没有属性' _HttpTransport__get_request_url'

这是我的代码:

import uuid
from googleads import adwords
from googleads import oauth2

def main(client):
    # Initialize appropriate service.
    user_list_service = client.GetService(
        'AdwordsUserListService', version='v201702')

    # Construct operations and add a user list.
    operations = [
    {
        'operator': 'ADD',
        'operand': {
            'xsi_type': 'BasicUserList',
            'name': 'Mars cruise customers #%s' % uuid.uuid4(),
            'description': 'A list of mars cruise customers in the last 
    year',
            'membershipLifeSpan': '365',
            'conversionTypes': [
                {
                    'name': ('Mars cruise customers #%s'
                             % uuid.uuid4())
                }
            ],
            # Optional field.
            'status': 'OPEN',
            }
        }
    ]
    result = user_list_service.mutate(operations)

if __name__ == '__main__':
    CLIENT_ID = 'xxx'
    CLIENT_SECRET = 'xxx'
    REFRESH_TOKEN = 'xxx'
    DEVELOPER_TOKEN = 'xxx'
    USER_AGENT = 'xxx'
    CLIENT_CUSTOMER_ID = 'xxx'
    oauth2_client = oauth2.GoogleRefreshTokenClient(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)
    adwords_client = adwords.AdWordsClient(DEVELOPER_TOKEN, oauth2_client, USER_AGENT,client_customer_id=CLIENT_CUSTOMER_ID)
    main(adwords_client)

0 个答案:

没有答案