Hi Sarah,
Thank you for reaching out. You could refer to this code snippet as an example to remove the existing user list in the Google Ads API. You would need to use the remove operator instead.
Thanks and regards,
Xiaoming, Google Ads API Team
Hello Xiaoming
The code snippet you suggested in the previous email didn’t help I’m afraid.
The snippet of C# code I ran trying to remove the userList :
UserListServiceClient userListService = _adsClient.GetService(Services.V4.UserListService);
UserListOperation userListOperation = new UserListOperation { Remove = audienceResourceName };
try
{
MutateUserListsResponse response = userListService.MutateUserLists(customerId.ToString(), new UserListOperation[] { userListOperation });
return response.Results.FirstOrDefault()?.ResourceName;
}
catch (GoogleAdsException e)
{
}
but I got an exception message :
Message: Status(StatusCode=InvalidArgument, Detail="Request contains an invalid argument.")
Failure: { "userListError": "USER_LIST_MUTATE_NOT_SUPPORTED" }, Creating user list without setting type in oneof user_list field, or creating/updating read-only user list types is not allowed.
Request ID: G78DCEJdFWgwRVnAQExVwg
I don't think there's anything wrong with the above C# code, because the same syntax of code works for removing a campaign :
CampaignServiceClient campaignService = _adsClient.GetService(Services.V4.CampaignService);
CampaignOperation operation = new CampaignOperation() { Remove = campaignResourceName };
try
{
MutateCampaignsResponse response = campaignService.MutateCampaigns(customerId.ToString(), new CampaignOperation[] { operation });
return response.Results.FirstOrDefault()?.ResourceName;
}
catch (GoogleAdsException e)
{
}
The failure reason doesn't make sense to me - "Creating user list without setting type in oneof user_list field, or creating/updating read-only user list types is not allowed.",
because I was trying to 'Remove' the userlist not creating/updateing.
Can you please check if that's a bug in the GoogleAds Api for removing a userlist ? Will you fix it ? Thank you.
Best Wishes
Sarah
Hi Sarah,
Thank you for reaching out. This could happen when the user list is marked as read_only when a user is not the list ownership or it is a certain list type such as similar_user_list. Please ensure that you are the owner of the user list and the user list is not read_only.
Thanks and regards,
Xiaoming, Google Ads API Team