I’ve been trying to create a custom audience and insert a user list into it, adding user data the audience to implement Remarketing features.I’ve followed a REST interface document
with no problems, but looks like the part of adding the user list into it isnt working.I’ve followed the documentation guide and can’t see why isnt working, someone can please help me with this?Bellow, the code os the method who create the custom audience and makes the import into adwords:
UserListOperation operation = new UserListOperation();
operation.setOperand(userList);
operation.setOperator(Operator.ADD);
UserListReturnValue result = userListService.mutate(new UserListOperation[]{operation});
UserList userListAdded = result.getValue(0);
System.out.printf(
"User list with name '%s' and ID %d was added.%n",
userListAdded.getName(), userListAdded.getId());
Long userListId = userListAdded.getId();
MutateMembersOperation mutateMembersOperation = new MutateMembersOperation();
MutateMembersOperand operand = new MutateMembersOperand();
operand.setUserListId(userListId);
List<Member> members = new ArrayList<>(EMAILS.size());
for (String email : EMAILS) {
String normalizedEmail = textUtils.toNormalizedString(email);
Member member = new Member();
member.setHashedEmail(textUtils.toSHA256String(normalizedEmail));
members.add(member);
}
String firstName;
String lastName;
String countryCode;
String zipCode;
String tempCountryCode;
String tempZipCode;
for (JsonValue jsonValue : jsonUsers) {
JsonObject obj = jsonValue.asObject();
firstName = obj.get("firstName").toString();
lastName = obj.get("lastName").toString();
countryCode = obj.get("country").toString();
zipCode = obj.get("zip").toString();
AddressInfo addressInfo = new AddressInfo();
addressInfo.setHashedFirstName(textUtils.toSHA256String(textUtils.toNormalizedString(firstName)));
addressInfo.setHashedLastName(textUtils.toSHA256String(textUtils.toNormalizedString(lastName)));
addressInfo.setCountryCode(clearString(countryCode));
addressInfo.setZipCode(clearString(zipCode));
Member memberByAddress = new Member();
memberByAddress.setAddressInfo(addressInfo);
members.add(memberByAddress);
}
operand.setMembersList(members.toArray(new Member[members.size()]));
mutateMembersOperation.setOperand(operand);
mutateMembersOperation.setOperator(Operator.ADD);
MutateMembersReturnValue mutateMembersResult =
userListService.mutateMembers(new MutateMembersOperation[]{mutateMembersOperation});