I am trying to split my products into 3 listing groups (2 pf which are 
product types and 1 others group because apparently this is required) based 
on product type, I am following the example from the github examples.:
def main(client, customer_id, ad_group_id, replace_existing_tree):
    """Adds a shopping listing group tree to a shopping ad group, divided 
by product type.

    Args:
        client: An initialized Google Ads client.
        customer_id: The Google Ads customer ID.
        ad_group_id: The ad group ID to which the node will be added.
        replace_existing_tree: Boolean, whether to replace the existing 
listing
            group tree on the ad group. Defaults to false.
    """
    # Get the AdGroupCriterionService client.
    ad_group_criterion_service = 
client.get_service("AdGroupCriterionService")

    # Optional: Remove the existing listing group tree, if it already exists
    if replace_existing_tree:
        remove_listing_group_tree(client, customer_id, ad_group_id)

    # Create a list of ad group criteria operations.
    operations = []

    # Construct the listing group tree "root" node (Subdivision node).
    ad_group_criterion_root_operation = create_listing_group_subdivision(
        client, customer_id, ad_group_id
    )
    ad_group_criterion_root_resource_name = (
        ad_group_criterion_root_operation.create.resource_name
    )
    operations.append(ad_group_criterion_root_operation)

    # Construct the listing group unit nodes for different product types.
    product_type_dimension_info = client.get_type("ListingDimensionInfo")

    # Biddable Unit node: (Product Type "kroonluchters")
    product_type_dimension_info.product_type.value = "kroonluchters"
    product_type_dimension_info.product_type.level = 
client.enums.ProductTypeLevelEnum.LEVEL1
    operations.append(
        create_listing_group_unit_biddable(
            client,
            customer_id,
            ad_group_id,
            ad_group_criterion_root_resource_name,
            product_type_dimension_info,
            300_000,
        )
    )

    # Biddable Unit node: (Product Type "muurlampen-verlichting")
    product_type_dimension_info.product_type.value = 
"muurlampen-verlichting"
    product_type_dimension_info.product_type.level = 
client.enums.ProductTypeLevelEnum.LEVEL1
    operations.append(
        create_listing_group_unit_biddable(
            client,
            customer_id,
            ad_group_id,
            ad_group_criterion_root_resource_name,
            product_type_dimension_info,
            200_000,
        )
    )

    # Create an "others" case for the subdivision
    # Ensure the "others" case is properly set up
    other_dimension_info = client.get_type("ListingDimensionInfo")
    
other_dimension_info.product_type.CopyFrom(product_type_dimension_info.product_type)
    other_dimension_info.product_type.value = "others"
    
    ad_group_criterion_other_operation = create_listing_group_subdivision(
        client,
        customer_id,
        ad_group_id,
        ad_group_criterion_root_resource_name,
        other_dimension_info,
    )
    ad_group_criterion_other_resource_name = (
        ad_group_criterion_other_operation.create.resource_name
    )
    operations.append(ad_group_criterion_other_operation)

    # Biddable Unit node for "others"
    operations.append(
        create_listing_group_unit_biddable(
            client,
            customer_id,
            ad_group_id,
            ad_group_criterion_other_resource_name,
            other_dimension_info,
            50_000,
        )
    )

    # Add the ad group criteria.
    try:
        mutate_ad_group_criteria_response = (
            ad_group_criterion_service.mutate_ad_group_criteria(
                customer_id=customer_id, operations=operations
            )
        )
    except Exception as e:
        print(f"An error occurred while adding ad group criteria: {e}")
        return

    # Print the results of the successful mutates.
    print("Added ad group criteria for the listing group tree with the 
following resource names:")
    print(f"\t{ad_group_criterion_root_resource_name}")
    print(f"\t{ad_group_criterion_other_resource_name}")

    print(f"{len(mutate_ad_group_criteria_response.results)} criteria 
added.")

However I get:
>, errors {
  error_code {
    criterion_error: LISTING_GROUP_SUBDIVISION_REQUIRES_OTHERS_CASE
  }
  message: "Subdivided listing groups must have an \"others\" case."
  trigger {
    int64_value: -1
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "listing_group"
    }
    field_path_elements {
      field_name: "type"
    }
  }
}
errors {
  error_code {
    criterion_error: INVALID_LISTING_GROUP_HIERARCHY
  }
  message: "Ad group is invalid due to the listing groups it contains."
  trigger {
    int64_value: -1
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 1
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "listing_group"
    }
  }
}
errors {
  error_code {
    criterion_error: INVALID_LISTING_GROUP_HIERARCHY
  }
  message: "Ad group is invalid due to the listing groups it contains."
  trigger {
    int64_value: -1
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 2
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "listing_group"
    }
  }
}
errors {
  error_code {
    criterion_error: LISTING_GROUP_SUBDIVISION_REQUIRES_OTHERS_CASE
  }
  message: "Subdivided listing groups must have an \"others\" case."
  trigger {
    int64_value: -2
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 3
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "listing_group"
    }
    field_path_elements {
      field_name: "type"
    }
  }
}
errors {
  error_code {
    criterion_error: DUPLICATE_LISTING_DIMENSION_TYPE
  }
  message: "There are dimensions with duplicate dimension type."
  trigger {
    string_value: "product_type"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 4
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "listing_group"
    }
    field_path_elements {
      field_name: "case_value"
    }
  }
}
request_id: "KJ_Ci6yA1UiCOB2J1TGsJw"
, 'KJ_Ci6yA1UiCOB2J1TGsJw')

Does someone know how to fix this?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/44a09135-ff43-4c88-9f06-f330b31bdb06n%40googlegroups.com.

Reply via email to