The getUserList method is to select a list of List ID and find a match with the passed in id.
May I know which library or query I can use to get this list of List ID? This is the List ID I am referring to, [image: LIST_ID.PNG] As for the upload of the user list (mutateMembers method), it is to upload a list containing Email Address, Country Code, First Name, Last Name, Phone, Zip to the List ID. May I know which library I should use to update or add the list to the List ID? Thank you, Derek On Monday, 21 November 2022 at 11:26:00 UTC+8 derek wrote: > Hi > I recently took over this process to upload user lists to Google audience. > I need to migrate it from AdWords API (Java client library) to the Google > Ads API (Java client library). > I am not able to find the equivalent Ads API of the AdWords API used. > > Still trying to understand the process and about Google Ads Audience but I > think these methods are the main part of the process. > > private void getUserList(){ > log.info("get user list [{}]", audienceId); > int offset = 0; > //MR54558 reset userList for each List ID > userList = null; > SelectorBuilder builder = new SelectorBuilder(); > Selector selector = builder > .fields(AdwordsUserListField.Id, > AdwordsUserListField.Size, AdwordsUserListField.Status) > .orderAscBy(AdwordsUserListField.Id) > .offset(offset) > .limit(PAGE_SIZE) > .build(); > try { > UserListPage page; > do{ > page = userListService.get(selector); > UserList[] userLists = page.getEntries(); > if(userLists != null && userLists.length > 0){ > for(UserList ul : userLists){ > > if(audienceId.equalsIgnoreCase(ul.getId().toString())){ > userList = ul; > break; > } > } > } > offset += PAGE_SIZE; > selector = builder.increaseOffsetBy(PAGE_SIZE).build(); > }while (offset < page.getTotalNumEntries() && userList == > null); > } catch (RemoteException e) { > log.error("fail to get user list [{}]", audienceId, e); > } > } > > private void mutateMembers(List<String> data, Operator operator) > throws RemoteException { > MutateMembersOperation operation = new MutateMembersOperation(); > MutateMembersOperand operand = new MutateMembersOperand(); > operand.setUserListId(userList.getId()); > > List<Member> members = new ArrayList<>(data.size()); > for(String email : data){ > Member member = new Member(); > member.setHashedEmail(getHashedEmail(email)); > members.add(member); > } > operand.setMembersList(members.toArray(new > Member[members.size()])); > operation.setOperand(operand); > operation.setOperator(operator); > > MutateMembersReturnValue result = userListService.mutateMembers( > new MutateMembersOperation[]{operation} > ); > > UserList[] userListResult = result.getUserLists(); > String message = String.format("[%s], [%s] members %s in audience > [%s][%s], upload status [%s], [%s] records found from csv", > new SimpleDateFormat("yyyyMMdd").format(now().toDate()), > members.size(), operator.getValue(), userList.getId(), > userList.getName(), > ((CrmBasedUserList) > userListResult[0]).getDataUploadResult().getUploadStatus().getValue(), > data.size()); > log.info("upload result : {}", message); > if (Operator.ADD == operator) { > addNotifyMessage(message); > } > } > > May I know what are the Google Ads API I should use to achieve the same > objectives? > > Please let me know if the full listing of the codes is needed. > > Thank you, > Derek > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@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 "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/1f682a3d-7267-42f0-b2d2-80a84f3eb6b9n%40googlegroups.com.