suds.WebFault: Server raised fault: 'Cannot construct an instance of com.google.ads.api.services.datax.userlists.LogicalUserListOperand because it is abstract. You are probably missing an @Uses annotation while invoking public abstract com.google.ads.api.services.datax.userlists.UserListReturnValue com.google.ads.api.services.datax.adwordsuserlist.AdwordsUserListService.mutate(java.util.List) throws com.google.ads.api.services.common.error.ApiException with params [[com.google.ads.api.services.datax.adwordsuserlist.v201502.jaxbgen.UserListOperation@16687106]].'#!/usr/bin/python
#coding=UTF-8
from datetime import date
from datetime import datetime
from datetime import timedelta
from googleads import adwords
(...)
def createNewList(client, list_a, list_b):
# Initialize appropriate service.
adwords_user_list_service = client.GetService(
'AdwordsUserListService', version='v201502')
rules = [
{
'ruleOperands': [list_a],
'operator': 'ALL'
},
{
'ruleOperands': [list_b],
'operator': 'NONE'
}
]
# Create the user list with no restrictions on site visit date.
combination_user_list = {
'xsi_type': 'LogicalUserList',
'name': 'Bouncers list created at %s'
% datetime.today().strftime('%Y%m%d %H:%M:%S'),
'description': 'Users who visited list A but not B',
'rules': rules
#'startDate': today.strftime('%Y%m%d'),
#'endDate': end_date.strftime('%Y%m%d')
}
# Create operations to add the user lists.
operations = [
{
'operand': user_list,
'operator': 'ADD',
} for user_list in [combination_user_list]
]
# Submit the operations.
user_lists = adwords_user_list_service.mutate(operations)
# Display results.
for user_list in user_lists['value']:
print (('User list added with ID %d, name "%s", status "%s", list type'
' "%s", accountUserListStatus "%s", description "%s".') %
(user_list['id'], user_list['name'],
user_list['status'], user_list['listType'],
user_list['accountUserListStatus'], user_list['description']))
adwords_client = adwords.AdWordsClient.LoadFromStorage()
createNewList(adwords_client, list_a, list_b)DEBUG:suds.transport.http:opening (https://adwords.google.com/api/adwords/rm/v201502/AdwordsUserListService?wsdl)
DEBUG:suds.transport.http:sending:
URL: https://adwords.google.com/api/adwords/rm/v201502/AdwordsUserListService
HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'Authorization': 'Bearer [removed]', 'SOAPAction': b'""', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': b'""'}
MESSAGE:
b'<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="https://adwords.google.com/api/adwords/rm/v201502" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201502" xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://adwords.google.com/api/adwords/rm/v201502" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><tns:RequestHeader><tns:clientCustomerId xmlns:tns="https://adwords.google.com/api/adwords/cm/v201502">[removed]</tns:clientCustomerId><tns:developerToken xmlns:tns="https://adwords.google.com/api/adwords/cm/v201502">[removed]</tns:developerToken><tns:userAgent xmlns:tns="https://adwords.google.com/api/adwords/cm/v201502">[removed] (AwApi-Python, googleads/3.5.0, Python/3.4.3)</tns:userAgent><tns:validateOnly xmlns:tns="https://adwords.google.com/api/adwords/cm/v201502">false</tns:validateOnly><tns:partialFailure xmlns:tns="https://adwords.google.com/api/adwords/cm/v201502">false</tns:partialFailure></tns:RequestHeader></SOAP-ENV:Header><ns0:Body><ns1:mutate><ns1:operations><ns2:operator>ADD</ns2:operator><ns1:operand xsi:type="ns1:LogicalUserList"><ns1:name>[removed] list created at 20150717 14:18:00</ns1:name><ns1:description>Users who visited list A but not B, C and D</ns1:description><ns1:UserList.Type>LogicalUserList</ns1:UserList.Type><ns1:rules><ns1:operator>ALL</ns1:operator><ns1:ruleOperands xsi:type="ns1:ExpressionRuleUserList"><ns1:id>102489659</ns1:id><ns1:isReadOnly>false</ns1:isReadOnly><ns1:name>List A created at 20150717 14:17:57</ns1:name><ns1:description>Users who visited a page where URL contains [removed]</ns1:description><ns1:status>OPEN</ns1:status><ns1:accessReason>OWNED</ns1:accessReason><ns1:accountUserListStatus>ACTIVE</ns1:accountUserListStatus><ns1:membershipLifeSpan>30</ns1:membershipLifeSpan><ns1:listType>RULE_BASED</ns1:listType><ns1:UserList.Type>ExpressionRuleUserList</ns1:UserList.Type><ns1:rule><ns1:groups><ns1:items><ns1:StringRuleItem><ns1:key><ns1:name>url__</ns1:name></ns1:key><ns1:op>CONTAINS</ns1:op><ns1:value>[removed]</ns1:value></ns1:StringRuleItem></ns1:items></ns1:groups></ns1:rule></ns1:ruleOperands></ns1:rules><ns1:rules><ns1:operator>NONE</ns1:operator><ns1:ruleOperands xsi:type="ns1:ExpressionRuleUserList"><ns1:id>102489779</ns1:id><ns1:isReadOnly>false</ns1:isReadOnly><ns1:name>List B created at 20150717 14:17:58</ns1:name><ns1:description>Users who visited a page where URL contains [removed]</ns1:description><ns1:status>OPEN</ns1:status><ns1:accessReason>OWNED</ns1:accessReason><ns1:accountUserListStatus>ACTIVE</ns1:accountUserListStatus><ns1:membershipLifeSpan>30</ns1:membershipLifeSpan><ns1:listType>RULE_BASED</ns1:listType><ns1:UserList.Type>ExpressionRuleUserList</ns1:UserList.Type><ns1:rule><ns1:groups><ns1:items><ns1:StringRuleItem><ns1:key><ns1:name>url__</ns1:name></ns1:key><ns1:op>CONTAINS</ns1:op><ns1:value>[removed]</ns1:value></ns1:StringRuleItem></ns1:items></ns1:groups></ns1:rule></ns1:ruleOperands><ns1:ruleOperands xsi:type="ns1:ExpressionRuleUserList"><ns1:id>102489899</ns1:id><ns1:isReadOnly>false</ns1:isReadOnly><ns1:name>List C created at 20150717 14:17:58</ns1:name><ns1:description>Users who visited a page where URL contains [removed]</ns1:description><ns1:status>OPEN</ns1:status><ns1:accessReason>OWNED</ns1:accessReason><ns1:accountUserListStatus>ACTIVE</ns1:accountUserListStatus><ns1:membershipLifeSpan>30</ns1:membershipLifeSpan><ns1:listType>RULE_BASED</ns1:listType><ns1:UserList.Type>ExpressionRuleUserList</ns1:UserList.Type><ns1:rule><ns1:groups><ns1:items><ns1:StringRuleItem><ns1:key><ns1:name>url__</ns1:name></ns1:key><ns1:op>CONTAINS</ns1:op><ns1:value>[removed]</ns1:value></ns1:StringRuleItem></ns1:items></ns1:groups></ns1:rule></ns1:ruleOperands><ns1:ruleOperands xsi:type="ns1:ExpressionRuleUserList"><ns1:id>102490019</ns1:id><ns1:isReadOnly>false</ns1:isReadOnly><ns1:name>List D created at 20150717 14:17:59</ns1:name><ns1:description>Users who visited a page where URL contains [removed]</ns1:description><ns1:status>OPEN</ns1:status><ns1:accessReason>OWNED</ns1:accessReason><ns1:accountUserListStatus>ACTIVE</ns1:accountUserListStatus><ns1:membershipLifeSpan>30</ns1:membershipLifeSpan><ns1:listType>RULE_BASED</ns1:listType><ns1:UserList.Type>ExpressionRuleUserList</ns1:UserList.Type><ns1:rule><ns1:groups><ns1:items><ns1:StringRuleItem><ns1:key><ns1:name>url__</ns1:name></ns1:key><ns1:op>CONTAINS</ns1:op><ns1:value>[removed]</ns1:value></ns1:StringRuleItem></ns1:items></ns1:groups></ns1:rule></ns1:ruleOperands></ns1:rules></ns1:operand></ns1:operations></ns1:mutate></ns0:Body></SOAP-ENV:Envelope>'
ERROR:suds.client:<suds.sax.document.Document object at 0x10b29f4e0>rule = {'operator': 'ALL','ruleOperands': [{'UserList': {'xsi_type': 'BasicUserList','id': INSERT_USER_LIST_ID_A_HERE,}},{'UserList': {'xsi_type': 'BasicUserList','id': INSERT_USER_LIST_ID_B_HERE,}}]}# Construct operations and add a user list.operations = [{'operator': 'ADD','operand': {'xsi_type': 'LogicalUserList','name': 'Logical #%s' % uuid.uuid4(),'description': 'Logical test','rules': [rule],}}]