collection_size_error: TOO_MANY
I am trying to add users to the newly created audience in Google ads API but I am getting the following response from the API. I want to understand what is possibly causing this error and how to fix this?
Set<String> userList; //this contains Hashed data(email of user that I want to upload) List<UserDataOperation> userDataOperations = new ArrayList<>(userList.size()); for (String user : userList) { UserDataOperation userDataOperationEmail = UserDataOperation.newBuilder().setCreate( UserData.newBuilder() .addUserIdentifiers(UserIdentifier.newBuilder().setHashedEmail(user).build()) .build()).build(); userDataOperations.add(userDataOperationEmail); }
From the discussion in the comments, it seems that a likely cause for the error is that you're trying to add more than 100'000 users to a user list at a time in your AddOfflineUserDataJobOperationsRequest.
Try splitting up your user IDs into multiple requests with the same job resource name.
I am using the code given in the image above to add a user to the audience(userLst that I created in google ads API). But I see that when I add more than 10 users(when the userList set size is greater than 10) when making calls to google ads I get this Collection size error. Please check the code snippet updated in ques
Please provide code snippets as text, not as an image.
Please find the code snippet below Set userList; //this contains Hashed data(email of user that I want to upload) List userDataOperations = new ArrayList(userList.size()); for (String user : userList) { UserDataOperation userDataOperationEmail = UserDataOperation.newBuilder().setCreate( UserData.newBuilder() .addUserIdentifiers(UserIdentifier.newBuilder().setHashedEmail(user).build()) .build()).build(); userDataOperations.add(userDataOperationEmail); }
Please take a look at meta.stackexchange.com/questions/22186/… As it stands, your code is very hard to read.
formatted the code @dorian